SCRIPTING - HOW TO SCHEDULE SERVER REBOOT

If you need to plan one shot (fixed time and date) reboot you could use this command.

It will create a scheduled task, that can be executed with or without any one logged on.

(no password saving is required)

Obviously any other customization is easily to be rearranged.

schtasks /create /sc once /tn taskname /tr "shutdown -r -f” /st hh:mm /sd dd/mm/yyyy /NP

 

/NP   No password is stored.  The task runs non-interactively

            as the given user.  Only local resources are available.      

 /SC   schedule    Specifies the schedule frequency.

                                    Valid schedule types: MINUTE, HOURLY, DAILY, WEEKLY,

                                    MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE,                                     ONEVENT.                                                          

 

/SD   startdate    Specifies the first date on which the task runs. The

                                   format is dd/mm/yyyy. Defaults to the current

                                    date. This is not applicable for schedule types: ONCE,

                                    ONSTART, ONLOGON, ONIDLE, ONEVENT.                           

                                                                               

/ST   starttime     Specifies the start time to run the task. The time

                                    format is HH:mm (24 hour time) for example, 14:30 for

                                    2:30 PM. Defaults to current time if /ST is not

                                    specified.  This option is required with /SC ONCE.

               

/TN   taskname    Specifies the string in the form of path\name

                                    which uniquely identifies this scheduled task.

                                                                               

/TR   taskrun      Specifies the path and file name of the program to be

                                    run at the scheduled time.

                                    Example: C:\windows\system32\calc.exe            

[UPDATE 2023.08.08]

Windows 2003/2008/2008 R2/2012/2012 R2 this is correct syntax.

schtasks /create /sc once /tn taskname /st hh:mm /sd dd/mm/yyyy /NP /tr "shutdown -r -f”