Some tips to help you schedule scripts to run unattended

Some programming experience required!

Below I have scheduled some simple scripts to run with the Windows task scheduler. Here are the scripts:

test_1.bat

echo [ %date% %time% ] test_1.bat ran >> "test.log"
call test_2.bat

test_2.bat

echo [ %date% %time% ] test_2.bat ran >> "test.log

The first script prints to a file “test.log” the date and time and then calls test_2.bat which also prints the date and time to the same “test.log” file. This provides a simple simulation of the real backup. Here we can be sure that the scheduler is setup correctly and we understand the elements needed to set up the real backup correctly.

  1. Start the Task Scheduler
    • ScheduleTask.jpg
  1. Select the Task Scheduler Library
  2. Add a new folder. I suggest BIM Server.
    • CreateFolder.jpg
  3. Select your new folder
  4. Create a task
    • CreateTask.jpg
    1. General Tab: Give a name.
    2. General Tab: User must have Administrative rights
    3. General Tab: Run whether user is logged on or not
    4. General Tab: Run with highest privileges
      • GeneralTab.jpg
    5. Triggers Tab: New
    6. New Trigger: Choose how often and when to start (since this is a test I have scheduled it to run one “One Time”, and the time I set to be a few minutes after I finished the scheduling)
    7. New Trigger: Make sure it is enabled
    8. New Trigger: Okay Dialog
      • triggertab.jpg
    9. Actions Tab: New
    10. New Action: Browse for where the script is
    11. New Action: Set the “Start in” to the folder where the scripts are located (If you don’t set this only the first script will run –unless you add a path to every point where the “Call” command is used in the scripts)
    12. New Action: Okay Dialog
      • action.jpg
    13. General Tab: Okay
    14. General Tab: Add your password as required for the account that will run the task
  5. Wait for task to be run by scheduler, or force it to run by clicking on Run in the far right Actions panel. (I suggest you wait for the scheduler to do it for the first time to make sure you have everything set up right)
    • Setup_testwithRun.jpg
  6. Look at the contents of the “test.log” to make sure they indicate the time of the scripts should have run. If the file is not there, or the time is not consistent with when it ran, you need to go through the steps to find out what went wrong. (probably the “start in” folder was not set correctly)
    • logResult.jpg
  7. Now that you are comfortable with the test program. Set scheduling up for the real backup scripts. If the authority of the user is not high enough it is possible that the backups will not run.
  8. The real backup will take longer to run and most likely you will schedule it for some time in the middle of the night or early morning. In this case you might want to make sure that it runs correctly using “Run.”