Operating System Shut down when I press the sleep button (1 Viewer)

Stéphane Lenclud

Development Group
  • Team MediaPortal
  • April 29, 2013
    Germany Germany
    Country flag
    I like my HTPC to shut down when I hit the power button on my remote control.
    The problem is that an MCE remote actually sends the sleep command when you hit the power button.
    By default on Windows (7, 8 and 10) the sleep button sends your computer into sleep mode.
    In your settings you can actually configure what is Windows doing in response to both power and sleep buttons.


    Here are the options you have for your power button:


    Now sadly the sleep button won't let you choose that shut down option:


    However you can still tell Windows to shut down when the sleep button is pressed and that's how:
    • Run a command prompt as administrator.
    • Run powercfg -getactivescheme and note the scheme UID.
    • Run powercfg -q <scheme_guid> and note the UID for "Power buttons and lid" subsection.
    • Run powercfg -q <scheme_guid> <sub_guid> and note the UID for "Sleep button action" power setting.
    • Run powercfg -setacvalueindex <scheme_guid> <sub_guid> <setting_guid> <setting_index> where setting index is 3 for shut down.
    The command you will end up running to change that setting should look like:
    powercfg -setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 96996bc0-ad50-47ec-923b-6f41874dd9eb 3
    Obviously the UIDs on your machine should be different so make sure you don't just copy and paste that command. You need to workout the UIDs for your setup as described above.

    Once you have executed that command properly, go back to your system settings where you should see the following:


    Notice how the sleep button entry is empty. That's ok, it's just that the UI still won't show that shut down option.
    Now restart Windows for the changes to take effect, then you can try out your newly programmed sleep button.

    Special thanks goes to Wray Smallwood for publishing that solution.
    Microsoft community post
    Last edited:

    Anthony Vaughan

    MP Donator
  • Premium Supporter
  • June 25, 2015
    United Kingdom United Kingdom
    Country flag
    I've just seen this posting and found it very useful.

    I am now using MediaPortal 1.25 and Windows 10 2004 and the index of 3 is no longer accepted. I think your fix works on the no-battery option but does it also work for the battery powered option? The CMD prompt shows that index 002 now says shut down, but when I set the index to 2, the machine still sleeps.

    Are there new instructions for this procedure to enable shut down when the power button on the remote is pressed?

    Anthony Vaughan

    MP Donator
  • Premium Supporter
  • June 25, 2015
    United Kingdom United Kingdom
    Country flag
    Okay. Thanks for letting me know.

    My workaround for the moment is to use the Exit MediaPortal (without options) button to close down MediaPortal - I used to use the Exit MediaPortal with options - and now use the power button on my remote to put the computer to sleep and then turn off the power to the computer. It's a bit clunky, bit it does work. I'm using the DefaultWideHD skin.

    BTW, the reason I am worrying about this is that I use the central configuration facility in MediaPortal to have all the client configuration, skins and client databases on a single computer - the reason I do this is because I can make a configuration change on one client and it will be picked up by all of the other clients - and, suddenly and I don't know why, the lock on the VideoDatabaseV5.db3 file started not to be released when I took the shutdown option from Exit MediaPortal. This used to work fine for several years, but has now stopped working, hence the need to be able to shutdown the computer down using a WMC remote.

    All of this is necessary because I've developed a synchronisation app that ensures that all of the client databases get updated with changes to any single client database and it does this by picking up when a client database is updated and the lock on it is released. The failure to release the lock on shutdown has had a cascade effect hence my need to be able to turn off my computer remotely, which is where you came in.

    Thanks for your contribution. Even though it is only putting my machine to sleep, rather than shutting it down, it provides me with a working solution and I am very grateful for that.


    Users who are viewing this thread

    Top Bottom