Search code examples
batch-filecmdwindows-server-2012-r2windows-task-scheduler

windows service - start service using batch file using task scheduler on windows 2012 server R2


I have created a batch file startservice.bat to start a windows service and scheduling this batch files using task scheduler on windows server 2012 R2.

startservice.bat

NET START myservice

But after scheduler runs a cmd pop up comes but service is not actually started.

If I run this batch file manually then service starts.


Solution

  • On my 2012 R2 server, I attempted to reproduce the problem you describe. The batch file always starts the service when I run via a scheduled task and I never get a cmd pop up.

    Your question did not specify scheduled task settings. You may need to enable the "Run with highest privileges" option on the General tab of your scheduled task.

    Your action should call the batch file directly or you can call CMD. Either way, make sure you call the full path of the batch file.

    cmd /c C:\startservice.bat