How to add item to right-click menu when NOT selecting a folder or file? [duplicate]
How do I add a menu item to my context menu to open up powershell (or any other arbitary application) when I right-click inside Windows Explorer?
I found tons of links on how to add menu items when doing this: (selecting a folder; example link)
...but couldn't find any instructions on how to add menu items when doing this: (not selecting a folder or file)
I did find this and tried adding powershell to HKEY_CLASSES_ROOT\Directory\Background\shell\
, (loosely based on the instructions I found and linked above) but it didn't work for me.
I'm running Windows 7, by the way. Also, I'm currently interested in adding only PowerShell, but I'd prefer a general solution I can apply to add any program to the context menu.
Steps:
-
Save this code in a file called
powershell.reg
:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell] @="&Powershell" [HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command] @="C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
If your Windows folder is not
C:\WINDOWS
, change the script accordingly. Make sure to use double backslashes.Double-click
powershell.reg
.When asked if you're sure, click
Yes
.Click
OK
.
This is the result:
This works, of course, for any program. Just replace every occurrence of Powershell
and the full path of powershell.exe
by, e.g., Windows Calculator
and C:\\WINDOWS\\system32\\calc.exe
.
The basic process is just as Dennis described in his answer.
The addition I have to make allow you to customize the icon displayed for the menu and also specify the placement of the item in the context menu.
Context Menu Icon
- Add an Icon String Value entry under the
HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell
key. - Specify the path to the icon for the item.
Position of Menu Item
- Add a Position String Value entry under the
HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell
key. - Specify
Top
to place the item at the top of the menu orBottom
to place it at the bottom of the menu.
Below is a registry script of the procedures I described above. Paste it into notepad and save it as powershell.reg (or anything else but with the .reg extension). Then import it into the your system registry to add the menu item.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell]
@="&Powershell"
"Icon"="C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
"Position"="Top"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command]
@="C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
If you're feeling geeky enough and want to put multiple programs in a cascading menu, you can follow the instructions here.