2

Is there a way to display the Windows shutdown dialog box from c#?

Shutdown dialog box

I found a command that I can use with System.Diagnostic.Process.Start

taskkill /im explorer.exe

But doesnt works on Windows 8

user962284
  • 670
  • 1
  • 12
  • 29

3 Answers3

0

You could use shutdown.exe instead of trying to kill explorer.:

shutdown.exe /i /t 0
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
0

I haven't tried calling it from a C# process, but shutdown /i pulls a GUI on Windows 8 for me. Note that it isn't the same UI though.

Godeke
  • 16,131
  • 4
  • 62
  • 86
0

I know it's an old question, but for those searching for an answer, at least in recent Windows systems (propably also in older ones) a good solution is to send a WM_CLOSE message to the window with classname "progman", this will trigger the default cancelable Windows shutdown dialog as shown in the screenshot above. In plain C this would be:

SendMessage(FindWindow(_T("progman"), NULL), WM_CLOSE, 0, 0);
user15566053
  • 41
  • 1
  • 2