Reputation:
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
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
Reputation: 46496
I find PowerShell to be more elegant than other Windows scripting options.
(New-Object -Com Shell.Application).ShutdownWindows()
Upvotes: 3
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