Show shut down dialog from command line, Windows 8

8

1

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.

camerongray

Posted 2012-10-16T20:37:02.103

Reputation: 81

3Open a command prompt, type "shutdown /i" no quotes and hit enter key, not quite the same gui but will perform the same function. – Moab – 2012-10-16T21:20:34.253

1

If its just about remapping the key you can use Autohotkey for that, alternatively there are also Registry hack to remap keys. MOre here.

– Ankit – 2012-10-19T19:56:20.287

1Typically the system power button does this. It shouldn't be necessary to assign a second button. Is it not working on your system? – Michael Hampton – 2012-10-20T14:36:10.823

Answers

3

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.

George Duckett

Posted 2012-10-16T20:37:02.103

Reputation: 5 350

1

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)

AndreaCi

Posted 2012-10-16T20:37:02.103

Reputation: 1 310

1

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.

Mike van der Lee

Posted 2012-10-16T20:37:02.103

Reputation: 11