Although many network applications (backup software being the most obvious example) have their own built-in schedulers, we often want to run our own scripts, automatically and unattended, on a predetermined schedule. It's a simple process, and in this HowTo we'll sum up how you do it on Windows 2000 Server (a process which, incidentally, is pretty much identical on any version of Windows 2000, Windows XP or Windows Server 2003).
Windows 2000's task scheduler, being a graphical gizmo, is very easy to set up. Before you try scheduling jobs, though, it’s worth checking that the scheduler is running. In the Settings control panel, check that the item labelled Task Scheduler is labelled as both Started and Automatic – this means that the scheduler will run when the machine reboots.
To add a scheduled task, go to the Scheduled Tasks control panel and open Add Scheduled Task. You'll see the first screen of a simple wizard. First, you're asked to select the program you want to run; it'll list the programs it knows about, but if you're asking it to run, say, a batch file or VBScript file you've created yourself, you'll have to click Browse and point the scheduler at the script, wherever you've put it. (It's a good idea to put all your scheduled scripts in one place, so you know where to find them when you want to make changes).
Next, you're invited to pick a schedule. You can choose to run jobs daily/weekly/monthly, on a one-off basis, when the computer starts up, or each time you log on. Just pick the appropriate button and move on. Depending on what option you chose on the previous screen, the next screen's contents will vary; if you chose "Once only", for instance, you'll be asked simply for the date and time you want to run the job; if you chose "Weekly", you'll be asked which days you want to run it, and at what time of day; if you chose "Daily" you're asked only for the time of day and whether you want to run every day, every weekday, or every n days.
Finally, you need to consider what file permissions the job you're scheduling requires and provide the scheduler with an appropriate login name, password and domain that will permit the script to access whatever resources it needs. When you've provided the appropriate details, you'll be asked whether you want to finish or look at the "advanced" properties of the job.
The "advanced" properties dialog that the wizard sends you to is actually the same as you'll see if you right-click on a task's icon in the Scheduled Tasks window and choose Properties. Nine times out of ten you won't need to use these screens but they have a few useful features.
First, you can edit the schedule should you so desire – a useful feature as it gives a much more flexible scheduling capability than the one you're given within the setup wizard. More importantly, though, you can instruct the system to kill off a job if it's been running for what you deem an excessive time (the default is 72 hours, which is rather excessive). If you're running tasks on a laptop, rather than a machine that's always on mains power, you can dictate that jobs shouldn't be allowed to run (or should be killed if they've already started) when the machine switches to batteries. The second particularly useful aspect of the "advanced" properties box is that it allows you to run the task as if it had been started in a particular directory on the disk – so if you've written a batch script that uses lots of relative path names, this feature is an alternative to having to change every path in the script to an absolute one.
Find your next job with techworld jobs