Microsoft

Integrate a custom Shutdown menu into the Windows 8 Desktop context menu

Greg Shultz shows you how to tweak the registry and add a cascading Shutdown menu to a Windows 8 context menu.

In the article Add a Shutdown menu to the Windows 8 desktop, I showed you how to add a Shutdown menu to the taskbar. While that technique works fine, I have never really been satisfied with it because the menu takes up so much space on the taskbar for something that I use so infrequently. Well, I was recently poking around on the Microsoft MSDN site and found a lot of information about working with context menus by editing the registry. Along the way, I learned how to add cascading menus to a context menu, such as the one you encounter when you right click on the desktop. That got me thinking about the possibility of adding the Shut Down menu to the Desktop context menu.

After a bit of experimentation, I was able to figure out how to make it work in Windows 8 and developed the Shut Down menu shown in Figure A.

Figure A

I added a cascading Shut Down menu to the Desktop context menu.

As you can see, I went full bore and added every possible option to my Shut Down menu. I then grouped the options into functional categories, added separators to delineate the categories, and even included appropriate icons.

After I was finished with my creation I showed it to several colleagues. While the overall consensus was that it was a great technique, a couple folks mentioned that they wouldn't have used all of the options, and one guy said that he thought that the icons were overkill. All valuable input.

This blog post is also available as a TechRepublic Screenshot Gallery.

So as I was creating my article outline I decided to take into account that there would be folks who would want the whole menu as I have created it and there would be folks who would like to be able to customize the menu to their own liking. For the former, I have created a REG file that can be used to instantaneously add my full Shut Down menu to your Windows 8 system. For the latter group of folks, I'll walk you, step-by-step, through the process of editing the registry to manually add the Shut Down menu to your Windows 8 system. Even if you opt to use the REG file method, I encourage you to read through the manual steps in case you later decide that you want customize the menu.

Make a backup

Before you begin, keep in mind that the Registry is vital to the operating system and changing it can be dangerous if you inadvertently make a mistake. As such, you should take a time to back up your system by creating a system image as I showed you in Restore Windows 8 with System Image Recovery. That way if anything goes awry, you can restore your system and get right back to work.

Overview

Before we get started let's take a generalized look at the procedure that we'll be performing as we create a custom Shut Down menu on Windows 8's Desktop context menu. To make this happen, we'll be working in two different sections of the registry.

You'll go to the HKEY_CLASSES_ROOT\DesktopBackground\Shell key and create a new subkey called Shut Down. You'll then add several entries to this new subkey to configure it as a cascading menu on the Desktop's context menu. Essentially, this new subkey will create an outline of the cascading menu.

You'll then go to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell subkey. Here, you'll define entries containing the command lines for each item that you want to add to the Shut Down menu.

As you may know, the registry in the Windows operating system is huge and navigating in it can be tricky. To make navigation easier, I'll show you how to use two features in the Registry Editor: Find and Favorites. With this in mind, let's jump in.

Launching the Registry Editor

To launch the Registry Editor in Windows 8, use the [Windows] + Q keystroke to access the Apps Search Settings page. Then, type Regedit in the text box and click Regedit.exe, as shown in Figure B. If you prefer, you can use the [Windows] + R keystroke to bring up the Run dialog box. Then, type Regedit in the Open text box and click OK.

Figure B

Accessing the Registry Editor from the Start screen is easy.

Either way that you launch the Registry Editor, you'll see a User Account Control dialog box and will need to click the Yes button. You'll then see the Registry Editor.

Creating the Shut Down cascading menu

Once you have the Registry Editor up and running, locate and right-click on HKEY_CLASSES_ROOT key and select the Find command. When you see the Find dialog box, type DesktopBackground in the text box and make sure that only the Keys check box is selected, as shown in Figure C. To continue, click the Find Next button.

Figure C

Type DesktopBackground in the Find dialog box.

When you arrive at the HKEY_CLASSES_ROOT\DesktopBackground key, double click on it to expand its tree. Then, double click on the Shell key to expand its tree. Now, pull down the Favorites menu, select the Add to Favorites command, type DesktopBackground in the text box, and click OK. Now, you can get back to the DesktopBackground key from the Favorites menu any time you need to while you are creating your cascading menu.

To continue, right-click on the Shell key and then select the New | Key command as shown in Figure D. When you see the new key appear, name it Shut Down.

Figure D

Right click on the Shell key and select the New|Key command.
After you create the Shut Down key, select it, and you'll see that it contains a single string value called Default. Just leave that key as it is. To create the outline of the cascading menu, you'll add four more string values to the Shut Down key. The Value name and Value data that you'll add are listed in Table A.

Table A: The String values that you'll add to the Shut Down key.

Value name

Value data

Icon shell32.dll,215
MUIVerb Shut Down
Position bottom
SubCommands restart;|;shutdown;hybridshutdown;|;sleep;hibernate;|;lock;logoff;switch

Let's take a closer look at these string values. As we do, look back at the Shut Down cascading menu shown in Figure A. Obviously, the Icon value specifies which icon to use - the icon is in position 215 in the Shell32.dll file. Note that there are no blank spaces in this line and the items are separated by a coma. The MUIVerb value specifies the name to assign to the menu. The Position value, which is set to bottom, specifies that the new menu should appear at the bottom on the Desktop context menu.

The SubCommands value is a bit more elaborate. This line creates the outline for the cascading menu or more specifically specifies the order in which the items will appear on the menu. As you can see, there are no blank spaces in this line and each item is separated by a semicolon. The pipe symbols are used to insert separators in the menu. Also keep in mind that the items on this line refer to the keys in the CommandStore key not on the menu itself, which is why they are in lowercase and don't match the names shown on the menu. (We'll add these keys to the CommandStore key in the next section.)

You can customize your menu by changing the icon, using a different name for the menu, changing the position, or by eliminating some of the items from the SubCommands string.

Now, to add each of these string values to the Shut Down key, right click on the Shut Down key and select the New | String Value command, as shown in Figure E. In the case of the first string value, when you see the new string value appear, name it Icon.

Figure E

Right click on the Shut Down key and select the New|String Value command.
Then double click the Icon value. When the Edit String dialog box appears, type shell32.dll,215 in the Value data text box, as shown in Figure F. Then click OK.

Figure F

Type the string from Table A in the Value data text box.
Repeat these steps to add the other three string values listed in Table A. When you are done, your Shut Down key should look like the one shown in Figure G.

Figure G

The Shut Down key will contain these four string values.

Adding the commands

Now that we have created our cascading menu structure, we'll add the commands for each item on the menu. If you have chosen to eliminate some of the items from the SubCommands string above, you'll adjust your steps accordingly.

To begin this portion of the technique, locate and right-click on HKEY_LOCAL_MACHINE key and select the Find command. When you see the Find dialog box, type CommandStore in the text box, make sure that only the Keys check box is selected, and then click the Find next button.

When you arrive at the HKEY_LOCAL_MACHINE\CommandStore key, double click on it to expand its tree. Then, double click on the shell key to expand its tree. Now, pull down the Favorites menu, select the Add to Favorites command, type CommandStore in the text box, and click OK. Now, you can get back to the CommandStore key from the Favorites menu any time you need to while you are creating your cascading menu.

At this point, you are going to add two keys to the shell key for each one of the commands that you want to appear on your menu. The first key will be a name from the SubCommands value in the Shut Down key. Inside this first key, you'll then add two string values: Default and Icon. Below the first key, you'll add a subkey named command. Inside this key, you'll add one string value: Default. The keys that you will create and the string values that you will add are shown in table in Figure H. I know that this may sound confusing at first, but bear with me and it will become clearer as we work through an example.

Figure H

This table shows all the keys and string values that you will use to create the full Shut Down menu.

As you can see, to make it easier to decipher the contents of this table, I've separated each set of keys and string values for each command you could add to the menu. The main key is in blue and a red border separates each key. Just add the keys that you specified earlier in the SubCommands value in the Shut Down key. If you decide that you don't want to include the icons on your menu, simply omit the Icon string value.

Let's begin by creating the restart key. To do so, right-click on the shell key and select the New | Key command. When you see the new key appear, name it restart. This key name must be all lowercase!

After you create the restart key, select it and you'll see that it contains a single String Value called Default. Now, double click the Default value. When you see the Edit String dialog box, type Restart in the Value data text box, as shown in Figure I. Then click OK.

Figure I

Double click the Default value and type Restart in the Value data text box.
Now, right click on the restart key and select the New | String command. When you see the new string appear, name it Icon. Next, double click the Icon value. When you see the Edit String dialog box, type comres.dll,4 in the Value data text box and click OK. When you do, your restart key will look like the one in Figure J.

Figure J

At this point you will have the Default and Icon string values in the restart key.
Now that you have created the Default and Icon string values in the restart key, you'll need to add the command key. To do so, right click on the restart key and select the New | Key command. When you see the new key appear, name it command. This key name must be all lowercase! Now, double click the Default value inside the command key. When you see the Edit String dialog box, type Shutdown -r -f -t 00 in the Value data text box and click OK. When you do, your command key will look like the one in Figure K.

Figure K

The command key only contains the Default string value.
Now, you can repeat these steps and use the information in the table in Figure H to add any of the other commands that you want to put on your custom Shut Down menu. When you are done, your CommandStore\shell key will look something like the one shown in Figure L. This screen shot shows the structure after adding each of the commands to the CommandStore\shell key.

Figure L

This screen shows the structure after adding each of the commands to the CommandStore\shell key.

Using the Reg files

As I mentioned, I created a REG file that can be used to instantaneously add my full Shut Down menu to your Windows 8 system. In addition, I have created a second REG file that will instantaneously remove the full Shut Down menu from your Windows 8 system. You can download both these files in the linked zip file. The files are named AddShutDownMenu.txt and RemoveShutDownMenu.txt. When you want to use them, you'll need to rename the file extension from .txt to .reg.

When you are ready to add the Shut Down menu to your Windows 8 system, just double click the AddShutDownMenu.reg file. When you do, you'll see a UAC like the one shown in Figure M. Just go ahead and click Yes.

Figure M

Just click Yes to get thru the UAC.
You'll then be prompted to confirm that you want to allow the Reg file to update the registry, as shown in Figure N. Again, just go ahead and click Yes.

Figure N

At this confirmation prompt, just click Yes.
Once the changes have been added to the registry, you'll see one more confirmation dialog box, shown in Figure O. Just click OK and you'll be able to use the options on your new Shut Down menu.

Figure O

Once the changes have been added to the registry, you'll see one more confirmation dialog box.

Tracking down icons

To be able to find icons and determine their positions, I downloaded a very simple, standalone program called IconView, shown in Figure P, from Neuber Software. The program is Free and perfectly performs the task at hand.

Figure P

IconView makes it easy to find icons and their positions.

What's your take?

What do you think about creating a Shut Down menu on Windows 8's Desktop context menu? Will you try it? As always, if you have comments or information to share about this topic, please take a moment to drop by the TechRepublic Community Forums and let us hear from you.

Also read:

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

22 comments
Chicago Charles
Chicago Charles

I'm wondering if there's a command to shut down and bypass updates? This used to be an option on Win 7. It was handy when I needed to shut down my computer right away without waiting for the updates to be installed; that was postponed until the next startup. Is this possible in Win 8.1?

Chicago Charles
Chicago Charles

This was quite helpful; thank you! One small glitch, however. In Windows 8.1, the icon address you cited for "Switch User", imageres.dll,220, returns a pushpin. The address for the icon in your illustration is comres.dll,1; dsprop.dll,1; dsuiext.dll,3; dsuiext.dll,12; dsuiext.dll,14; or dsuiext.dll,24, to name a few. (Found under C:\Windows\System 32.) 

bcdalai
bcdalai

Thank you very much for the post... Specifically the new Windows 8 users...

TNT
TNT

While I love Win 8, I admit that having to click to the Start screen, charms bar, and Settings just to get to shut down options is a bit tedious. I'll be using this reg hack starting tonight!

Gremeleon
Gremeleon

There are numerous ways to shut down W8 but this makes the process quick and clean from the desktop. I lock my system regularly when I walk away and this is a "slicker ...(uuughh)" way of doing that too!! I Love it. Thanks Greg!!

simonschilder
simonschilder

Very nice way of shutting down windows, since the default way is not very intuitive. Except for the lock, which is quicker using windows+L

Jesus.Rivera
Jesus.Rivera

Does this work "as is" with Windows 7 or can it even be done in 7?

khiatt
khiatt

Full menu, all icons, that's the way to go. Thanks.

awraynor
awraynor

I saw the file after I added everything manually. Otherwise, I love it.

midlantic
midlantic

Very slick! By the way, just the Windows key + I works as well.

Slayer_
Slayer_

That's a good way to do it. Now what else can we put there?

Mark W. Kaelin
Mark W. Kaelin

The lack of an obvious way to shut down a Windows 8 machine has been a constant complaint seen on the TechRepublic Forums. Does Greg's Registry hack make your life easier now?

Chicago Charles
Chicago Charles

Update: The correct icon is also at imageres.dlll,224 rather than 220.

Greg Shultz
Greg Shultz

...Shutdown tile on the Start screen looks like an interesting approach. However, it only provides the three main options: Shutdown, Retart, and Log Off

TNT
TNT

Holding down the Windows logo key while pressing the letter "L" on the keyboard is the quickest way to lock a Windows PC.

Slayer_
Slayer_

Though we already have a start menu. Give it a try, let us know if it works.

mistercrowley
mistercrowley

I thought that's what CTRL-ALT-DEL was for and then click Shut Down..... Just sayin'....

patrick.oosterling
patrick.oosterling

Just realized that from the desktop (probably most used by us in Windows 8) the old ALT + F4 still does the job and gives me the available options to shutdown my pc or just make it go to sleep/hibernate etc. Are more people doing this?

Jesus.Rivera
Jesus.Rivera

Well I tried it and it actually works, I just had to change the icon for the "Switch User", it was not showing up for me, other than that, the whole thing works very nice in Windows 7

Greg Shultz
Greg Shultz

...keyboard shortcut still works perfectly in Windows 8 and can be used to display the Shut Down Windows dialog box from which you can access all the available options. However, because Alt + F4 is the "universal" Close command for whatever window currently has the focus, it can be tricky to use. For example, if Notepad currently has the focus, pressing Alt + F4 will close Notepad. In order to access the Shut Down Windows dialog box, you need to make sure that the Desktop or the Taskbar has the focus. So, if you are not adverse to using the keyboard, pressing Alt + F4 is indeed a viable way to shut down Windows 8.

Greg Shultz
Greg Shultz

...reporting back that this technique does work in Windows 7. I figured that it would but hadn't yet tested it. Good to hear that it works!

Editor's Picks