====== Using Windows Scheduler To Execute A Batch File ====== On Windows, Task Scheduler is a tool that allows you to create and run virtually any task automatically. ===== Open Windows Scheduler ===== From the Windows Start bar, search for Task Scheduler and click on the Task Scheduler App to open. {{search_windows_scheduler.png}} ==== Create A New Task ==== From the right panel on the Task Scheduler App, click ''Create Task'' to open the Create Task window. {{task_scheduler_1.png}} === General Tab === On the General tab add: * Name for task that clearly identifies it for you and other operators. * Description of task to explain what it does. * Check R''Run whether user is logged on or not''. * Check ''Run with highest privileges''. * Ensure the Configure for drop box is set to the appropriate operating system. {{task_scheduler_2.png}} === Triggers === On the Triggers tab, click ''New'' to create a new trigger for the scheduled script. On the New Trigger popup window: * Set the Begin the task to ''On a schedule'' * Under Settings, select the schedule you want the task to run on. * Under Advanced settings, select the option to repeat the task and how often it is required. ie repeat every hour indefinately for a task you want to run every hour of every day. * Ensure Enabled is checked. * Click ''OK'' to add the trigger to the scheduled task. {{task_scheduler_3.png}} === Actions Tab === On the Actions tab, click ''New'' to create a new action for the scheduled script. On the New Action popup window: * Ensure the Action drop down box is set to ''Start A Program''. * Click ''Browse'' and navigate to select the required batch file. * If your batch file uses relative file paths, add the starting directory in the ''Start In'' field. * Click ''OK'' to add the action to the scheduled task. {{task_scheduler_4.png}} === Conditions Tab === The Conditions tab allows you to set execution restrictions, such as wait for the computer to be idle for a set time before running the script or only if the computer is on AC power. As TapeTrack scripts are normally essential processes to keep your database up to date, these restrictions are normally not advisable. {{task_scheduler_6.png}} === Settings Tab === The settings tab has several options such as: * Allow the task to be run on demand (check). * Run task as soon as possible after a scheduled start is missed (check). * If task fails, restart every (uncheck). * Stop the task if it runs longer than 3 days (check). * If the task does not end when requested, force it to stop (check). * If the task is not scheduled to run again, delete it after (uncheck). * If the task is already running, then the following rule applies (Do not start new instance) {{task_scheduler_5.png}} Click ''OK'' to create task, if prompted enter the password to complete the setup of the scheduling. {{tag> technote windows_scheduler}}