There are a couple things to keep in mind when you use the Task Scheduler in Windows to run a batch file. Actually there are only two that get batch files working for me on most occasions.
Proper File Permissions
The first thing is that the batch file itself must have proper file permissions for the user you connect with inside Task Scheduler.
Here is an example.
This is a test batch file I created in a folder on a secondary hard drive where I keep some scripts. When I go in to security settings of the file, you can see my user does not have full permission, even though I’m the user who created the file!
This is because the file is created on a 2nd hard drive which is outside my user folder.
If I simply copy the test batch file from that drive onto my Desktop (which is in my user folder) and change nothing else, the permissions change to this:
Now it makes sense why Task Scheduler would not be able to start the batch file. If I run the task as ZACK\Zack but don’t have full control for that user on the batch file, it won’t run.
Often times people don’t realize this permission issue because they can easily double-click the batch file and run it manually and don’t know why Task Scheduler can’t. Or people will run the task as full administrator instead of as a user. This sometimes fixes it because the admin will naturally have full control anyway.
Set the Start in Field
If your script makes any kind of assumption as to what folder it is running in, be sure to fill in this field. Often people resort to this fix first before checking permission. There is a difference between the script not starting and the script not working. If the script doesn’t start, it could be permissions. If the script doesn’t work right, it could be the “Start In” field is not set.
I’m sure there are others reasons that could prevent a batch file from running via Task Scheduler, but these two issues cover most of the reasons.