简体   繁体   中英

How Restart Windows Server 2003 PC use C# in windows service?

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 ?

when I REBOOT my servers, i use shutdown /r /t 0

It reboots the server right then. Use at your own risk.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM