ingvarius
ingvarius

Reputation: 13

How to force reboot Windows 7 from inside a C# Windows Service

I need to (force) reboot Windows from inside a Windows Service written in C#. The ordinary way of doing it, from a desktop application, shutdown.exe, will probably not work at all? I assume I cannot run an EXE file from inside a service..

Upvotes: 0

Views: 592

Answers (2)

ingvarai
ingvarai

Reputation: 21

I have tested it, but it does not work inside a Windows Service, it seems..

Upvotes: 0

Remy Lebeau
Remy Lebeau

Reputation: 597051

Look at the Win32 API InitiateSystemShutdown() and/or InitiateSystemShutdownEx() function.

Also refer to this MSDN article: Shutting Down.

Upvotes: 1

Related Questions