16

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)?

  • 2
    It seems this feature has been removed since Vista. What about remapping a function key to the command taskkill /im explorer.exe – You'reAGitForNotUsingGit Apr 9 '16 at 21:54
  • 2
    How 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 Apr 9 '16 at 21:57
  • 2
    Have you actually tried running that command? It brings up the old school shutdown dialog. I just tried it on my Win 7. – You'reAGitForNotUsingGit Apr 9 '16 at 22:01
  • 2
    It 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 Apr 9 '16 at 22:03
  • 2
    That's odd. What happens if you do ALT + F4 while the desktop has focus? When I run that command, I get this: lh5.ggpht.com/_S0f-AWxKVdM/TWz_IW5zaHI/AAAAAAAAOdA/VckFmhXHNCE/… – You'reAGitForNotUsingGit Apr 9 '16 at 22:05
10
+25

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.

| improve this answer | |
  • If you don't mind, could you post a screenshot of the dialog? I'm just slightly curious. – Solomon Ucko Nov 12 '19 at 20:06
  • Note that Windows 10 Home does not come with the Group Editor Policy out of the box. It looks like there might be ways to enable that. – Paul Ivanov May 22 at 18:08
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).
| improve this answer | |
  • 1
    How is that a solution? – Michael Hoffmann Apr 10 '16 at 14:01
  • 1
    This 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 Apr 10 '16 at 14:23
  • 1
    shutdown /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 Apr 10 '16 at 14:45
  • Thank you. Those "kludges" are what I'm looking for. UV for the explanation. – Michael Hoffmann Apr 10 '16 at 16:46
  • 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 Apr 10 '16 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.