1. Open Task Scheduler
2. Create a new task
3. Fill out the settings in the general tab. How you want to configure the command and the user account running it. In this case, I am using a local administrator account, it will run if the user is logged in or not, run with highest privileges, and is configured for server 2019
4. Create and configure a new trigger
For our new tigger we are setting it to be run on a daily schedule, 5 am every day. Here you can also disable the task or have it expire after a specific date.
5. Once triggers are set, we can put the code in for setting up the reboot in the actions tab.
Here is where the code goes for executing the reboot
%SystemRoot%\system32\shutdown.exe -r -f -t 1 |
The task above has set a reboot of the system in one second. You can read below for other options that can be configured.
Shutdown
%SystemRoot%\system32\shutdown.exe -s -f -t 60 (Shutdown the system in 60 seconds)
Reboot
%SystemRoot%\system32\shutdown.exe -r -f -t 60 (Reboot the system in 60 seconds)
Here is a description of the parameters used above:
-s : The shutdown option. This will turn the computer off.
-r : The reboot option. This will reboot the system (turn it off and on again)
-f : forces all applications and services to close and/or stop.
-t : timeout before executing the shutdown or reboot (in seconds). The default is 20 seconds, but can be changed by adding a number right after it, separated by a space: for example, -t 60 for 60 seconds.
%SystemRoot%\system32\shutdown.exe -s -f -t 60 (Shutdown the system in 60 seconds)
Reboot
%SystemRoot%\system32\shutdown.exe -r -f -t 60 (Reboot the system in 60 seconds)
Here is a description of the parameters used above:
-s : The shutdown option. This will turn the computer off.
-r : The reboot option. This will reboot the system (turn it off and on again)
-f : forces all applications and services to close and/or stop.
-t : timeout before executing the shutdown or reboot (in seconds). The default is 20 seconds, but can be changed by adding a number right after it, separated by a space: for example, -t 60 for 60 seconds.
6. Conditions
Setup any additional conditions you want the to configure, such as only running if there is a network connection, if the system has been idle, etc.
7. Settings
Configuring additional settings such as the task being allowed to run on demand or running the task if it was missed.
References:
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb491003(v=technet.10)?redirectedfrom=MSDN
https://www.ryadel.com/en/windows-auto-reboot-shutdown-scheduled-task-scheduler-cron/