There are many reasons you may need to restart a server via task scheduler. My favorite reason is so I can reboot the server after patching without having to work late. 🙂
This example will restart a server every morning at 6:00 AM Monday through Friday, but will not restart it on the weekends.
Start / Administrative Tools / Task Scheduler
Right-click Task Scheduler Library (or optional sub folder) and create task.
General Tab
Name: Descriptive name such as: RestartOneTimeMorning0600am or: RestartWeeklySundayMorning0130am
Description: Put in your own description, such as: Scheduled after-hours server restart
When running the task, use the following user account: NT AUTHORITY\SYSTEM
* (Note: Select “SYSTEM” when browsing using “Change User or Group…”)
Check “Run with highest privileges”
Configure for: Windows 7, Windows Server 2008 R2
Triggers Tab
New…
Begin the task: On a schedule
Settings: Set your preferences. Be sure to select “Enabled” so it will run.
OK
Actions Tab
New…
Action: Start a Program
Program/script: C:\WINDOWS\system32\shutdown.exe
Add arguments: -r /t 300 /c “This server will restart in 5 minutes. Save and Exit NOW!” /d p:1:1
Start in: c:\windows\system32
Note: /t 300 sets it to restart in 300 seconds, which is 5 minutes. Change the # of seconds to meet your needs, and update the server restart message to reflect the appropriate time.
Leave the rest of the tabs at default.