Follow up to last night’s post on wget. The wget app (in my case) needs to run every couple hours during the day. Windows 2000 and higher has a built task scheduler which I could (and will) use to schedule the execution of the task, but to do this I’d have to type some kludgy command line arguments AND I’d have to have administrator access to the machine in order to change any of the properties of the task. There must be a better way… enter Windows Script files(.wsf), which is “.. a text document containing Extensible Markup Language (XML) code, incorporates several features that offer you increased scripting flexibility. (from MSDN). It’s kinda like ANT, except Windows specific.
My download wget script eventually looks like this:
http://someserver.com/myxmlpacket2.xml.gz
FileName.xml.gz
http://someserver.com/myxmlpacket.xml.gz
theNameofMyFile.xml.gz
Couple things to notice: a) a wsf is valid xml, b) you can run multiple jobs in one file, and c) you can reuse your existing VBS scripts. So now, seeing my wsf file, how would I call that using the Windows Task Scheduler? You want to run cscript.exe, which is in c:\$winnt$\system32\, so you’re run command would look like this:
C:\WINNT\system32\cscript.exe //Job:daypart c:\wget\wget.wsf
where ‘daypart’ is the name of the job within your wget.wsf file. Using WSF as a wrapper for the wget executable allows you to easily tasks to a specific jobs. Even better, you can access almost anything on a Windows system or network using VBScript/WSH, including accessing network connections, creating local applications, and managing the system registry.