views:

439

answers:

2

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?

+5  A: 

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.
John Feminella
Thanks a lot. Now I'm just curious about other ways to do it :)
+2  A: 

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

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

Jay Bazuzi