How to make the power button show a prompt in Windows 10

15

1

I dual-boot between Xubuntu and Windows 10. In Xubuntu, when I press the power button, a dialog pops up with buttons for shut down, restart, etc. I frequently use this to restart the computer, but I also use it when I want to shut it down, and I'd like to have the same thing in Windows, because (1) I keep pressing the power button out of habit instead of using the menus, and (2) like pushing the power button and then pushing an option on my touchscreen a lot better than pushing Windows+X->U->U, mostly because U (Shutdown) and I (Sign Out) are right next to each other, which leads to some mistakes when I'm trying to hastily shut down at the end of class.

I know how to change what the power buttons do from the Control Panel, but is there any way I can set the power button to prompt me for what I want to do every time I push it?

Or, better yet, is there any way to override the control panel's settings and make the power button launch an arbitrary executable or script that I could design myself (to match Xubuntu's menu)?

Michael Hoffmann

Posted 2015-12-29T00:50:11.203

Reputation: 385

2It seems this feature has been removed since Vista. What about remapping a function key to the command taskkill /im explorer.exe – You'reAGitForNotUsingGit – 2016-04-09T21:54:26.227

2How would killing explorer.exe help? I'm not saying it wouldn't, I just don't understand the connection. Is the OS's response to the power button controlled by explorer.exe, or is it a service that responds to it, or what? – Michael Hoffmann – 2016-04-09T21:57:17.260

2Have you actually tried running that command? It brings up the old school shutdown dialog. I just tried it on my Win 7. – You'reAGitForNotUsingGit – 2016-04-09T22:01:27.843

2It printed "SUCCESS: Sent termination signal to the process "explorer.exe" with PID 2484." on Windows 10, and didn't visibly do anything else... – Michael Hoffmann – 2016-04-09T22:03:28.510

2

That's odd. What happens if you do ALT + F4 while the desktop has focus? When I run that command, I get this: http://lh5.ggpht.com/_S0f-AWxKVdM/TWz_IW5zaHI/AAAAAAAAOdA/VckFmhXHNCE/shutdown%5B3%5D.png?imgmax=800

– You'reAGitForNotUsingGit – 2016-04-09T22:05:41.680

Something similar pops up in Windows 10, but it's not what I'm looking for. I still can't easily/accurately use my touchscreen to select a drop-down option. The input flow for that would be Windows+D->Alt+F4->(touch dropdown)->touch OK, which breaks if an application has a window open that demands focus, like a modal dialog. – Michael Hoffmann – 2016-04-09T22:10:01.743

So that dialog appeared when you did ALT + F4 on the desktop, but not when you ran the taskkill command? – You'reAGitForNotUsingGit – 2016-04-09T22:12:04.937

Yes, that's correct. – Michael Hoffmann – 2016-04-09T22:14:11.467

Could you try this? http://winaero.com/blog/how-to-create-shortcut-for-shutdown-windows-dialog/

– You'reAGitForNotUsingGit – 2016-04-09T22:16:28.977

I could probably try that, but as I said, the shut down dialog with a drop-down menu is not what I'm looking for. – Michael Hoffmann – 2016-04-09T22:21:03.053

If you are referring to the prompt similar to Win XP shut down- restart- sign out buttons, it has gone for good since Win Vista; it's been drop-down menu since then. – Sanny – 2016-04-10T00:29:29.057

No, I'm not necessarily referring to any built in prompt at all- please read the question, especially the last paragraph, and the bounty message. – Michael Hoffmann – 2016-04-10T00:43:34.507

Answers

9

There is no direct way to do this anymore. Windows XP used to have a feature in the Power control panel where you could set the power button to ask you what you want to do. However, that functionality was dropped in Windows Vista and later.

There is a way to simulate the behavior with local security policy, however.

  1. Launch the Local Group Policy Editor from the command line or your Run... dialog (gpedit.msc)
  2. Under Computer Configuration -> System, locate Display Shutdown Event Tracker and double-click it. Enable the policy and set the display mode to Always (screenshots below)

enter image description here

enter image description here

With this policy enabled, Windows will prompt you for the reason you are shutting down the computer. Not exactly a friendly "Do you want to shut down" box, but it does provide a backstop for when you hit the power button.

Wes Sayeed

Posted 2015-12-29T00:50:11.203

Reputation: 12 024

If you don't mind, could you post a screenshot of the dialog? I'm just slightly curious. – Solomon Ucko – 2019-11-12T20:06:15.557

3

I have spent some time trying all sorts of solutions that used to work, but which do not work any more in Windows 10 :

None of them did any good.

Conclusion: There is no way to intercept or abort the Power button. Once it is pressed it is end-game.

The only solution I could find is:

  1. Set the Power button to do nothing :
    In Power Options -> Change plan settings -> Change advanced power settings -> Power buttons and lid -> Settings -> Do nothing.
  2. To really turn off the computer, use the Start Menu or create a desktop shortcut.
    For emergencies only use a long press on the Power button (all changes to open documents will be lost and there is a tiny danger to the health of the system files).

harrymc

Posted 2015-12-29T00:50:11.203

Reputation: 306 093

1How is that a solution? – Michael Hoffmann – 2016-04-10T14:01:19.177

1This is not the solution that you asked for. But to have such a prompt would require a program that integrates much too deeply into Windows. I don't know of such a product, so I'm just summing up what you can do if you are not a hacker. There are ways to intercept the shutdown, but AFAIK no way to abort it. If you change the button action to Sleep, there might be ways to block that, but all of them are kludges that have their own problems. – harrymc – 2016-04-10T14:23:00.170

1shutdown /a is the only known method for aborting a shutdown, but it only works if this was started with the shutdown command itself, so doesn't apply to the power button. – harrymc – 2016-04-10T14:45:50.020

Thank you. Those "kludges" are what I'm looking for. UV for the explanation. – Michael Hoffmann – 2016-04-10T16:46:17.513

1

I'm not sure that these kludges will be able to block the power button.But you may try Insomnia or Caffeinated that supposedly will disable sleep for as long as they are running.

– harrymc – 2016-04-10T19:55:33.523