Reference

Windows Server 2008 Task Scheduler Won’t Execute .bat Files

When setting up scheduled tasks on Windows Server 2008 that execute batch files that work fine when started manually, but refuse to produce any results when started from or by the scheduler, even though it proudly shows Task completed, there a few quick things to check.

Tags: infrastructure server windows

File & Folder Permissions

Most problems with executing scheduled batch file tasks are caused by insufficient file and folder permissions.

  • The user account executing the batch file (see below) needs to have Full Control over the batch file, as well as the directory that contains the batch file. For some reason it is not sufficient to assign group permissions to the batch file, but the permissions have to be set for that particular user explicitly. For example, if the scheduled task executes under the Administrator account, granting access to the Administrators group will not be sufficient, but a separate entry with full control for the Administrator must be added.
  • If the batch files needs to write files to a target directory, for example when backing up a database or writing log files, the user account needs to have read and write access to that directory as well.

General Task Settings

  • Make sure the task is running under an appropriate account. You may choose an existing system account, an Administrator account or a special user created for just this purpose. Select the desired account on the General page of the Task Properties under When running the task, use the following user account.
  • If the task should be executed while nobody is logged on to the server, make sure that Run whether user is logged on or not is selected as well.
  • If the batch file needs to access non-local resources, such as network folders, the Do not store password box should be left unchecked.
  • If the batch file needs to access network resources, try to use the resource’s IP address instead of a mapped network drive, because it may have become unavailable.
  • Also on the General tab, configure the task Windows 7, Windows Server 2008 (R2).
  • Some tasks may require elevated permissions to execute, which can be granted by checking the Run with highest privileges box.

Action Settings

  • If the task does not run in the correct directory, edit the task’s action on the Actions tab and set Start in (optional) to the desired directory.
  • Make sure you’re not missing any arguments that may be expected by the batch file(s).

Verify that the scheduled task is producing the desired results by right-clicking the task in the Task Scheduler and selecting Run.