Show shut down dialog from command line, Windows 8

On Windows 8 if you press Alt+F4 with the desktop in focus, it displays a shutdown dialog. I was wondering if anyone knows of a way that this same dialog can be launched from the command line as I would like to remap the "ThinkVantage" button on my ThinkPad to display this message.

Does anyone know if this is possible? Using Task Manager I can see that the dialog is produced from explorer.exe but I have no idea how to execute it manually.


See this web page:

http://www.thewindowsclub.com/windows-shut-down-dialog-box


Open notepad and type the following:

(new ActiveXObject(“Shell.Application”)).ShutdownWindows();

Save this file with any name you like but provide it the .js format as mandatory for example Shutdown.js and pick All files as save as type. Save it to any location but create its shortcut to Desktop.

From there it appears you can launch it how you like, they create place it in a quick launcher folder. So I'd imagine you can invoke it from the command line.


You can also use shutdown /i which is a bit simpler, but doesn't show the same dialog box.


The command to initiate the system shutdown is...

shutdown

with these parameters, you whutdown immediately:

shutdown -s -t 00

with these parameters, the pc will reboot:

shutdown -r -t 00

There are a lot of other parameters, you can check them out here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/shutdown.mspx?mfr=true

typing

shutdown -i

will show another dialog (really ugly, actually)


I wanted to map this dialogue to a shortcut key myself and although there were good alternatives, the question wasn't answered to the question. I searched and fiddled around and came up with a script.

You can use AutoHotKey to let any key (Ctrl + Alt + 1 in this case) summon the dialogue with this script:

;Summon the Shutdown, Restart Windows dialogue by pressing Ctrl + Shift + 1
^!1::ControlSend, , !{F4}, ahk_class Progman

Which actually presses Alt + F4 while targeting the Windows Desktop.

Short instructions:

  • Download and install AutoHotKey;

  • Open notepad;

  • Paste the above code and save the file as {anyfilename}.ahk;

  • In windows explorer, right+click on the file and choose Compile;

  • Start the resulting {anyfilename}.exe

    Optionally:

  • You can put a shortcut to the exe in your Startmenu/Startup folder so it will start everytime when windows starts.

You can find a list and examples of Hotkeys @ http://ahkscript.org/docs/Hotkeys.htm

You can find special keys with the AutoHotKey script @ autohotkey.com/board/topic/21105-crazy-scripting-scriptlet-to-find-scancode-of-a-key/ For some special keys you need to put #InstallKeybdHook in your script.