Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I manage a few windows computers on a network and need them to restart at 3:45 am daily, for patches and Windows updates to be installed. I am only able to use the windows command-line to run scripts. I have the below Windows command-line script. However, when it is deployed to machines, they do not restart, the command-line script does not seem to schedule the restart task. Any guidance on this?

Please see script:

schtasks /create /tn "auto restart computer" /tr "shutdown -r" /sc daily /st 03:45 /f

What I have tried:

I have tried the mentioned script.

schtasks /create /tn "auto restart computer" /tr "shutdown -r" /sc daily /st 03:45 /f
Posted
Updated 2-Jul-21 9:19am
v3
Comments
Shemar Forsythe 2-Jul-21 15:56pm    
schtasks

Folder: \
TaskName Next Run Time Status
======================================== ====================== ===============
auto restart computer 7/3/2021 2:45:00 PM Ready

It works great, thank you so much for the assistance, Dave and Rick!

Your shutdown command should be "shutdown /r /t 0".

The /t is the amount of second to wait before shutting down the machine. Specifying it also enables the /f option, which forces all applications that are open to close without user interaction to close them.
 
Share this answer
 
Comments
Shemar Forsythe 2-Jul-21 15:00pm    
Hi, Dave I used your suggested modifications.

schtasks /create /tn "auto restart computer" /tr "shutdown /r /t 0" /sc daily /st 13:55 /f

It still doesn't seem to work. Note: I am using the PDQ Deploy application to run this script on host machines. (not sure if that could be the cause of the issue)
You probably need the full path, e.g.
C:\Windows\System32\shutdown.exe
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900