For a variety of reasons, it sometimes makes sense to reboot a Windows-based computer on a regular, perhaps daily basis. This "cures" a lot of ills by resetting processes, flushing caches, refreshing memory, and reestablish network connections. In a perfect world this would never be necessary, but the reality is, rebooting is frequently the easiest, best brute force, blunt instrument method of fixing what ails ya.
I recently tried (and, initially, failed) to set up automatic rebooting for a couple of my Virtual Machines. One is running Windows XP in a Virtual Server 7 environment, the other is running Windows Server 2003 in a Hyper-V environment. I tried using the ShutDown.Exe command
shutdown /r /f
command in a Scheduled Task. Alas, that worked only when logged on to the machine interactively, but not otherwise. Task Scheduler indicated an exit code of 0x15.
I tested this extensively, using various permutations of user accounts, permissions, rights, etc. I tried moving a copy of the shutdown.exe file to the root of the c drive. Absolutely nothing worked!
Through extensive searching, I came across a suggestion (in another context) to use Tsshutdn.Exe, which is the equivalent command for restarting a Terminal Server.
/v Display information about actions being performed. wait_time Seconds to wait after user notification before terminating all user sessions (default is 60).
/SERVER:servername The server to shut down (default is current).
/REBOOT Reboot the server after user sessions are terminated.
/POWERDOWN The server will prepare for powering off.
/DELAY:logoffdelay Seconds to wait after logging off all connected sessions (default is 30).
Apparently, when using a virtual machine, the technology used to connect to its console is the equavelent of Terminal Server, or RDP.