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
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 followingrunas /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 executeC:\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.
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.
TIP: please use absolute paths, relative paths ideally should not be an issue, but scheduler has an difficult time understanding them.
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.
One solution is you can run your '.bat' file with '.vbs' file and you can run this vbs file in windows scheduler.
You can do like this and i hope it will fix your issue.
For me, the problem was caused by the
.bat
included acd
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
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.