Let’s add an “Open Poweshell” option to the File Explorer context menu.
- Run Regedit
- Go to HKEY_CLASSES_ROOT\Directory\shell
- Add a new key to this, we’ll call ours power_shell as you may already see a PowerShell option and I don’t want to change that one
- Change Default for the key to the text you want display in your context menu, i.e. Open Powershell Here
- Add a new string value named Icon and in it’s value put C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
- Add a new key to the power_shell key, named command. This is what’s actually run in the Default key put C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command Set-Location -LiteralPath ‘%L’
This will now show the Open Powershell Here option when you click on a folder in File Explorer, but what about if you’re already in the folder and want to open powershell from the current folder, then…
- If you’ve closed Regedit then run Regedit again
- Go to HKEY_CLASSES_ROOT\Directory\background\shell
- Add a key named power_shell as before
- As before we now add a string value named Icon with the same value as above
- Again add a command subkey and with a slightly change add the following value into the Default key C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command Set-Location -LiteralPath ‘%V’ – note we change %L to %V