qakmak
qakmak

Reputation: 1377

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?

Upvotes: 0

Views: 180

Answers (2)

Vikas Gupta
Vikas Gupta

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

Brent
Brent

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

Related Questions