Monday, August 24, 2009

using windows scheduler for program scheduling

microsoft windows comes with a built in scheduler that can be used for a myriad of purposes

you can set your computer to reboot every night at 11:35pm for instance, or maybe you would like to schedule outlook and firefox to open every weekday morning at 7:55am so that they are both ready for your use when you sit down in the office at 8am

i like to use the windows scheduler to start batch files, the most common use of this for me is to fire off a simple script which will backup data on the computer at a given interval

the windows scheduler lives in the windows control panel, it is labeled as "scheduled tasks"


clicking "Add Scheduled Task" will walk you through a wizard to set the schedule you'd like, as well as what program or script to run at the scheduled date and time


you start off by selecting the program, there is a list of programs that the system already is aware of, you can also click "Browse" and browse to a script or program of your own choosing. in the example below i have browsed to a directory full of scripts, and i am choosing the "clear_pas_spool.bat" batch script file, if you are curious, this script simply empties out the print spooling directory for the pacific apparel systems application, sometimes pacific doesn't do the best job of handling this task and will leave crap behind, so we need to help it out a little bit by emptying the spool directory regularly


we then get a dialogue box where we can name the scheduled task, i usually just go with the default name. we are also given the choice of scheduling, in this case we are going to choose weekly, as i would like to schedule this event to take place each weekday of the week at 9:00pm


on the next screen we get to select the time of day, as well as which days of the week to run the scheduled task


next we must choose what user this task will run as, here we are using the user "superman", whom is part of the domain "myraddomain", if you are not doing this within a windows active directory domain, then it is safe to omit the domain, so instead of "myraddomain\superman", we would just use "superman"


almost done! clicking next will bring you to a screen to either complete the scheduled task with the settings we've defined, or you can go to an advanced menu which gives you more fine grained control over the scheduling, in most cases the screens we have covered will handle all of your scheduling needs

we should test the task, navigate back to the scheduled tasks directory, you will see your new task listed, along with a summary of the scheduler settings for the task


we can test the scheduled task by right clicking it, and selecting "run"


hopefully everything goes well with the test run of your first scheduled task! if there is a problem you can always delete the task and try again, or try right clicking the task, selecting "properties", then trying your hand at adjusting the settings

next time, we'll cover a very basic batch script to help you back up data to a compressed file, this script will work quite happily along with windows scheduled tasks, with the two of these working together you can make your own automated backup solution











No comments:

Post a Comment