有沒有辦法從服務中重新啓動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