How to add a “Open PowerShell Here” command to the context menu in Windows 8

If you right click a folder while holding down the shift key you’ll see a little command buried in the context menu called “Open command prompt here”.

This provides convenient access to the command prompt and drops you in the directory you right-clicked.

But today I need to challenge the status quo – why should the command prompt get all the glory?  I mean seriously: why isn’t there an Open PowerShell here command?

Today I’m going to show you how to hackup the registry so we can make your Powershell dreams comes true.

We’re going to be fiddling with the registry so we need to make sure that we back it up before we do anything.

Press the Windows Key + r and paste in the following command to the run box:

regedit

Windows 8.1 Regedit

After backing up the registry, we need to create a new sub-key that will provide the text in our context menu and the path to launching Powershell.


 

In the left pane, click through the folder maze until you find this:

Computer\HKEY_CLASSES_ROOT\Directory

Right-click the sub-key called shell and mouse over to New and pick Key.

New shell sub-key

Go ahead and name the key:

powershell

In the right pane double click (Default) and set the value to:

Open PowerShell here

Creating Open PowerShell here context menu

Now that we have the right-click “text” in place we just need to create the command to run when we click “Open PowerShell here”

Right-click the empty space in the right-pane and choose New and click on Key.

You should see a new key called command magically materialize below the powershell key in the left pane.

We just need to paste in the PowerShell path as the (Default) value for the command key.


My version of PowerShell is located here:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

But I can’t just paste it in like this because we need to explicitly escape the backslashes in the path and add a few extras so that the command windows doesn’t automatically close after opening.

Here’s the whole shebang:

C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'

You can see that I’m escaping each backslash with a backslash.  Also, the -NoExit option forces the PowerShell window to stay open.  And the Set-Location cmdlet with the LiteralPath switch tells us to open the window using the path of the current window.

That’s all there is to it.

The real beauty of this trick is that:

  • You don’t need to reboot after making the change
  • You don’t have to hold down the Shift key to make the option appear

You can now immediately right-click any folder and choose Open PowerShell here and zoom right to the shell.

Open PowerShell here hack

And there you have it!

How’s that for a hack?

PowerShell window

If this helped you please share the joy in the comments!

About

Connect with Vonnie on Twitter

Posted in Windows, Windows 8, Windows 8.1 Tagged with: ,
  • In Windows 10, I had to go back and rename the subkey that was automatically created by this step: “You should see a new key called command magically materialize below the powershell key in the left pane.” I got “new key #1”. But after that this does work with Windows 10! Though I have always wondered how to get an icon in the context menu… as DropBox has in your screenshot.