20

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
  • 435
  • 1
  • 4
  • 16
  • 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 09 '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 09 '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 09 '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 09 '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: http://lh5.ggpht.com/_S0f-AWxKVdM/TWz_IW5zaHI/AAAAAAAAOdA/VckFmhXHNCE/shutdown%5B3%5D.png?imgmax=800 – You'reAGitForNotUsingGit Apr 09 '16 at 22:05
  • 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 Apr 09 '16 at 22:10
  • So that dialog appeared when you did `ALT + F4` on the desktop, but not when you ran the `taskkill` command? – You'reAGitForNotUsingGit Apr 09 '16 at 22:12
  • Yes, that's correct. – Michael Hoffmann Apr 09 '16 at 22:14
  • Could you try this? http://winaero.com/blog/how-to-create-shortcut-for-shutdown-windows-dialog/ – You'reAGitForNotUsingGit Apr 09 '16 at 22:16
  • 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 Apr 09 '16 at 22:21
  • 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 Apr 10 '16 at 00:29
  • 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 Apr 10 '16 at 00:43

2 Answers2

13

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
  • 13,662
  • 6
  • 41
  • 76
5

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
  • 455,459
  • 31
  • 526
  • 924
  • 2
    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
  • 2
    `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](https://dlaa.me/Insomnia/) or [Caffeinated](http://desmondbrand.com/caffeinated/) that supposedly will disable sleep for as long as they are running. – harrymc Apr 10 '16 at 19:55