How to schedule two commands to run at certain times daily on Windows?

0

I'm on Windows Server 2012 and I need to restart a service at a certain point in time every day. I'm doing this using two commands, net stop and net start. This is what I have tried so far:

SchTasks /Create /SC DAILY /TN "AgentRestart" /TR "C:\Windows\System32\cmd.exe \c net stop 'test service' && net start 'testservice'" /ST 01:00

And

At 01:00:00AM /every:M,T,W,TH,F,SA,SU net stop "test service" 

At 01:00:30AM /every:M,T,W,TH,F,SA,SU net start "test service"

The first one doesn't work and the second one has a 30 second delay which is not desirable. Any better solutions?

trallgorm

Posted 2016-05-03T15:05:04.310

Reputation: 153

1"The first one doesn't work" doesn't work in what way exactly? What happens? Any error message? As you have it written here, the \c switch's slash in your SchTasks command is wrong; it should be /c. – Ƭᴇcʜιᴇ007 – 2016-05-03T15:37:49.877

Nice, glad to hear it worked! :) I stuck it in an official answer. – Ƭᴇcʜιᴇ007 – 2016-05-03T16:05:05.007

Answers

1

The \c switch's slash in your SchTasks command is invalid; it should be /c.

Ƭᴇcʜιᴇ007

Posted 2016-05-03T15:05:04.310

Reputation: 103 763