Reputation: 1377
The Server state is locked. C# in windows service, So I try use :
Process.Start("shutdown -r");
But looks like it's not working....
Is there any good way to Restart , Shutdown, Lock, Unlock use C# in windows service?
Upvotes: 0
Views: 180
Reputation: 4465
I don't know what restrictions apply for a windows service to spawn a child process.. For your needs, it may be worth trying and make a difference if you call the windows APIs directly.
See which one might suit your needs from - http://msdn.microsoft.com/en-us/library/windows/desktop/aa376883(v=vs.85).aspx
You can use http://pinvoke.net/ to find out how to declare almost any win api functions in your .net app.
Hope this helps.
Upvotes: 1
Reputation: 598
when I REBOOT my servers, i use shutdown /r /t 0
It reboots the server right then. Use at your own risk.
Upvotes: 1