[batch-file] Windows Task Scheduler doesn't start batch file task

I have a batch file with the code below to stop and start the SQL Report service:

net stop "SQL Server Reporting Services (MSSQLSERVER)" 

timeout /t 10

net start "SQL Server Reporting Services (MSSQLSERVER)"

I have set up the scheduled task to run daily, it currently runs as SYSTEM with the highest privileges set. I have set up the start in folder option on the action, and everything generally seems to be set up correctly. But when I run the task nothing seems to happen, it says the task has run but I cant see that the service has been restarted as it is meant to.

Can someone direct me to what I am missing? Thanks

This question is related to batch-file scheduled-tasks

The answer is


One solution is you can run your '.bat' file with '.vbs' file and you can run this vbs file in windows scheduler.

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("cron_jobs.bat"), 0, True

You can do like this and i hope it will fix your issue.


Make sure you set the 'Start in' and 'Program/script' options correctly. If your file address is: C:\Temp\foo.bat, set the 'start in' option to 'C:\Temp' and the 'Program/script' option to 'foo.bat'.

To set the 'Start in' option: Right click task in the task scheduler > Properties > Actions > Edit.

If this alone doesn't work then try moving the .bat file to a directory with basic permissions (maybe a shared directory for example).

I had a problem where my .bat file was located in a folder with some restrictive permissions on it, so that only my user account could access it. Even though I had set up the task scheduler to use my credentials it still failed. Moving the .bat file to another directory sorted the issue.


Wasted a lot of time on this silly issue!

add a cd command to where your batch file resides at the first line of your batch file and see if it resolves the issue.

cd D:\wherever\yourBatch\fileIs

TIP: please use absolute paths, relative paths ideally should not be an issue, but scheduler has an difficult time understanding them.


For me, the problem was caused by the .bat included a cd to a network drive. This failed, and then the later call to the program in that network drive did nothing.

I figured this out by adding > log.txt in the Add arguments field of the Edit action window for the task.


I had the same problem and none of the solutions worked. When I checked the history I figured out the issue. I had this warning

Task Scheduler did not launch task "\TASK_NAME"  because instance "{34a206d4-7fce-3895-bfcd-2456f6ed6533}"  of the same task is already running.

In the settings tab there is a drop down option for "If the task is already running, then the following rule applies:" and the default is "Do not start a new instance". Change that to "Run a new instance in parallel" or "Stop the existing instance" based on what you actually need to be done.

I know it's an old thread and multiple solutions are good here, this is just what worked for me. Hope it helps.


I was running this on a Windows Server OS. I worked for hours, only to find that the problem was that I had checked the "Run with highest privileges" checkbox. When checked on, it removes all drive mappings. And my .bat file was on the network.

enter image description here


This is a pretty old thread but the problem is still the same -

I tried multiple things, none of them worked -

  1. Added a Start In Path (without quotes)
  2. Removed the complete path of the batch file in the Program/Script field etc
  3. Added C:\Windows\system32\cmd.exe to the Program and added /c myscript.bat to the arguments field.

This is what worked for me -

Program/Script Field - cmd

Add Arguments - /c myscript.bat

Start In : Path to myscript.bat


My application failed to start via "Task Scheduler".

The error in "Event Viewer" is: System.IO.DirectoryNotFoundException

The "Task Scheduler" tries to run this application with the "SYSTEM" user. The problem was that a "network drive" was not mapped for the "SYSTEM" user. So what I did was, I created a ".bat" file and mapped the "network drive" before starting the application:

net use T: \\172.20.2.215\images
cd C:\MyApplication
start MyApplication.exe

So check your logs first: "Event Viewer" -> Windows Logs -> Application


Set 'Program/script' -- > file.bat set 'Start in' the rest of path (file.bat)


My problem was caused by OneDrive. OneDrive was syncing the folder my batch file lived in, and that seems to prevent Task Scheduler from executing it. (Doesn't anyone at MS test this kind of thing?)

Anyway by moving my batch file to a folder that wasn't in OneDrive the batch file could be started by Task Scheduler.


Try the code below:

Batchfile.bat:

cd c:\batchfilepath
net stop "SQL Server Reporting Services (MSSQLSERVER)" 
timeout /t 10
net start "SQL Server Reporting Services (MSSQLSERVER)"

I had the same problem. I believe it's a privilege problem. If you have "Run only when user is logged on" selected, then it won't happen.

You've hopefully figured it out by now, but I wanted to register it here for the next person who has wasted hours on this.


Configuration that worked for me:

  • In General tab: mark radio button - "Run only when user is logged on" <= important !
  • Program/script: just the path to script without quotes or nothing: C:/tools/script.bat
  • Add arguments: kept it empty
  • Start in: kept it empty

In settings, only 2 checkboxes marked:

  • Allow task to be run on demand
  • if the running task does not end when requested, force it to stop

On a Windows system which supports runas. First, independently run your program by launching it from a command line which was run as that user, like following

runas /user:<domain\username> cmd

Then, in that new command line, cd to the path from where you expect the task launcher to launch your program and type the full arguments, for example.

cd D:\Scripts\, then execute

C:\python27\pthon.exe script.py

Any errors that are being suppressed by task scheduler should come out to command line output and will make things easier to debug.


Had the same issue, make sure you check "Run only when user is logged on" at least that is what made my bat file alive again.


The solution is that you should uncheck (deactivate) option "Run only if user is logged on".

After that change, it starts to work on my machine.


For me it was trigger issue. By default it should On a Schedule in trigger tab. I had selected At log on and then I was waiting to run task. As it's name says at log on, means you have to logout and log on.

Try putting it on a Schedule and fire it every minute.

enter image description here