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:
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:
Right-click the sub-key called shell and mouse over to New and pick Key.
Go ahead and name the key:
In the right pane double click (Default) and set the value to:
Open PowerShell here
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:
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.
And there you have it!
How’s that for a hack?
If this helped you please share the joy in the comments!