frosty
frosty

Reputation:

Windows shutdown dialog

Is there a way to bring up the Windows XP shutdown dialog (the one with the three buttons – Suspend, Shutdown, Restart and Hibernate when Shift is pressed) using any language (preferred: C/C++, VB, Haskell, batches)?

I think I can load the msgina.dll in my C++ program, but I dunno what to do next – what function in the dll is used to show the dialog?

Upvotes: 4

Views: 1253

Answers (3)

user15566053
user15566053

Reputation: 121

I found out (14 years later) that a simple solution is to send a WM_CLOSE message to the "progman" window, this will trigger the standard shutdown dialog (tested in Win 10 and Win 11):

SendMessageW(FindWindowW(L"progman", NULL), WM_CLOSE, 0, 0);

Upvotes: 0

Jay Bazuzi
Jay Bazuzi

Reputation: 46496

I find PowerShell to be more elegant than other Windows scripting options.

(New-Object -Com Shell.Application).ShutdownWindows()

Upvotes: 3

John Feminella
John Feminella

Reputation: 311436

Assuming that your language has a way to do basic file I/O and invoke shortcuts on Windows, try this tip from here:

  • Create a new txt file somewhere on your system, open it and put in this one line: (new ActiveXObject("Shell.Application")).ShutdownWindows();
  • Save and close the file. Change the extension to *.js.
  • You can make a shortcut to that file to make it easy to shut down your system.

Upvotes: 5

Related Questions