Sunday, September 30, 2012

Add a Restart/Shutdown/Hibernate Desktop Context menu to your Windows 8 Desktop

This is inspired and based on the Add Shutdown and Restart to the Right-Click Context Menu in Windows 8 by the Help Desk Geek.

While I'm happy with Windows 8 user and look back on Windows 7, as Windows 7 users look back on Vista and XP, there are some things that do bug me a little. One thing, the number of steps it takes to Restart/Shutdown/Hibernate my system. I hibernate it at least once a day usually, and every time the number of clicks bugs me (assuming you've even enabled to the Charms/Settings/Power/Hibernate option... see this Addictive Tips post for how to do that, How To Enable Windows 8 Hibernate Option)

When I saw this post today, Add Shutdown and Restart to the Right-Click Context Menu in Windows 8, it was as if it were written just for me...

That said, there were some tweaks I had to make to make it work for me. First I wanted a Hibernate option, also I had to tweak the parameters and finally I wanted to also provide a remove regfile too...

image

Here's the regfile I used. Copy this into Notepad, save as a *.reg file, double click and apply it and you're good to go.

[NOTE: Standard "Be careful when doing anything registry related, that you can seriously jack up your computer if you, or the reg script you've copied, does something wrong." statement here. Also "Use at your own risk."]

--Start Do Not Copy This Line--

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Restart Computer]
"icon"="shell32.dll,-221"
"Position"="Bottom"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Shutdown Computer]
"icon"="shell32.dll,-329"
"Position"="Bottom"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\z-Hibernate Computer]
"icon"="shell32.dll,-331"
"Position"="Bottom"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Restart Computer\command]
@="shutdown.exe /r /f"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Shutdown Computer\command]
@="shutdown.exe /s /f"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\z-Hibernate Computer\command]
@="shutdown.exe /h /f"

--End Do Not Copy This Line--

Here's the remove regfile. If you save this as a .reg file and double-click on it, this will remove the above entries

--Start Do Not Copy This Line--

Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\Restart Computer]
[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\Shutdown Computer]
[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\z-Hibernate Computer]
[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\Restart Computer\command]
[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\Shutdown Computer\command]
[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\z-Hibernate Computer\command]

--End Do Not Copy This Line--

Why the "z-Hibernate..."? I just wanted that option to drop to the bottom of the list.

Also of note is the /f parameter. This is the Force option. It will force all app's to close and if there's unsaved work, you'll lose it. So if that kind of freaks you out and you'd like your app's to be able to delay a restart or shutdown and allow you to save unsaved work, etc, remote the "/f".

Interested the Windows 8 version of the Shutdown command?

C:\Users\Greg>shutdown /?
Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/f]

    [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

    No args    Display help. This is the same as typing /?.
    /?         Display help. This is the same as not typing any options.
    /i         Display the graphical user interface (GUI).
               This must be the first option.
    /l         Log off. This cannot be used with /m or /d options.
    /s         Shutdown the computer.
    /r         Full shutdown and restart the computer.
    /g         Full shutdown and restart the computer. After the system is
               rebooted, restart any registered applications.
    /a         Abort a system shutdown.
               This can only be used during the time-out period.
    /p         Turn off the local computer with no time-out or warning.
               Can be used with /d and /f options.
    /h         Hibernate the local computer.
               Can be used with the /f option.
    /hybrid    Performs a shutdown of the computer and prepares it for fast startup.
               Must be used with /s option.
    /e         Document the reason for an unexpected shutdown of a computer.
    /o         Go to the advanced boot options menu and restart the computer.
               Must be used with /r option.
    /m \\computer Specify the target computer.
    /t xxx     Set the time-out period before shutdown to xxx seconds.
               The valid range is 0-315360000 (10 years), with a default of 30.
               If the timeout period is greater than 0, the /f parameter is
               implied.
    /c "comment" Comment on the reason for the restart or shutdown.
               Maximum of 512 characters allowed.
    /f         Force running applications to close without forewarning users.
               The /f parameter is implied when a value greater than 0 is
               specified for the /t parameter.
    /d [p|u:]xx:yy  Provide the reason for the restart or shutdown.
               p indicates that the restart or shutdown is planned.
               u indicates that the reason is user defined.
               If neither p nor u is specified the restart or shutdown is
               unplanned.
               xx is the major reason number (positive integer less than 256).
               yy is the minor reason number (positive integer less than 65536).

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...