有没有办法从服务中重新启动Windows(Server 2008,Server 2012)?我试过了:从服务中重新启动Windows
System.Diagnostics.Process.Start("cmd.exe /c shutdown -f -r -t 0")
无济于事。我在这里看到的解决方案:
How to shut down the computer from C#
http://www.stackoverflow.com/questions/1215139/reboot-machine-from-a-c-wpf-app
,机器只是不希望重新启动。
当我从命令行运行命令时,它工作。从服务中运行时
cmd.exe /c shutdown -f -r -t 0
甚至
shutdown -f -r -t 0
什么也没有发生。我甚至修改它来运行:
c:\\windows\\system32\\cmd.exe /c c:\\windows\\system32\\shutdown.exe -f -r -t 0
而同样的结果,没有任何反应。再次从命令行运行时,它会正确重启。
我编辑了自己的冠军。请参阅:“[应该在其标题中包含”标签“](http://meta.stackexchange.com/questions/19190/)”,其中的共识是“不,他们不应该”。 –
http://stackoverflow.com/questions/22606426/process-start-does-not-work-when-called-from-windows-service –
当您从服务中执行此操作时会发生什么? – CathalMF