Is there a way to reboot Windows from within a service (Server 2008, Server 2012)? I've tried:
System.Diagnostics.Process.Start("cmd.exe /c shutdown -f -r -t 0")
To no avail. I've looked at solutions here:
How to shut down the computer from C#
http://www.stackoverflow.com/questions/1215139/reboot-machine-from-a-c-wpf-app
and the machine just doesn't want to reboot.
When I run the command from the command line, it works.
cmd.exe /c shutdown -f -r -t 0
or even
shutdown -f -r -t 0
Nothing happens when run from within the service. I even modified it to run:
c:\\windows\\system32\\cmd.exe /c c:\\windows\\system32\\shutdown.exe -f -r -t 0
And same result, nothing happens. Again when I run from the command line, it reboots properly.