Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

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)

right-clicking a folder

...but couldn't find any instructions on how to add menu items when doing this: (not selecting a folder or file)

not right-clicking anything

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.

share|improve this question

marked as duplicate by Karan, soandos, Tanner, Brad Patton, Breakthrough Jun 1 '13 at 1:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers 3

Resurrecting this for the sake of completeness, as I just went through this while reinstalling my machine.

[HKEY_CLASSES_ROOT\Directory\shell\powershell\command]
@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit cd '%1'"

[HKEY_CLASSES_ROOT\Directory\background\shell\powershell\command]
@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit cd '%v'"

The first registry key is for the right click on a folder and the second registry key corresponds to right clicking while selecting nothing.

share|improve this answer

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

  1. Add an Icon String Value entry under the HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell key.
  2. Specify the path to the icon for the item.

Position of Menu Item

  1. Add a Position String Value entry under the HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell key.
  2. Specify Top to place the item at the top of the menu or Bottom 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.

share|improve this answer
    
I am trying to do the same thing, the problem is as in the image in the question above, the file path shows it is a "Library" and these Registry additions only seem to work when in a folder not accessed by "Library"....any ideas how to get it to work with Library being in the file path? –  jasondavis Jan 13 '13 at 3:01
    
+1 for the Position=Top option, useful info. –  Curtis Tasker Sep 3 '13 at 17:37

Steps:

  1. 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"
    
  2. If your Windows folder is not C:\WINDOWS, change the script accordingly. Make sure to use double backslashes.

  3. Double-click powershell.reg.

  4. When asked if you're sure, click Yes.

  5. Click OK.

This is the result:

screenshot

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.