Skip to content

Instantly share code, notes, and snippets.

@lucianovalenca
Last active December 28, 2020 15:54
Show Gist options
  • Select an option

  • Save lucianovalenca/280444bd904ad5d8e197043a7d6a3b5a to your computer and use it in GitHub Desktop.

Select an option

Save lucianovalenca/280444bd904ad5d8e197043a7d6a3b5a to your computer and use it in GitHub Desktop.

Revisions

  1. lucianovalenca renamed this gist Dec 28, 2020. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions open → open_powershell_here
    Original file line number Diff line number Diff line change
    @@ -14,8 +14,15 @@ Steps:
    4. Create new key `command` under `powershellmenu`.
    5. Change the `Default` value of the `command` key to:

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

    6. Right-click on `powershellmenu` key and select `Permissions`, then set permissions to `Full control` for the Administrators group. (or whatever group/user)

    Then try right-clicking in some folder and it should work.
    Then try right-clicking in some folder and it should work.

    ------------------------

    I had to change the data in command (default) to
    `PowerShell -windowstyle hidden -Command "Start-Process cmd -ArgumentList '/s,/k,pushd,%V && start PowerShell && exit' -Verb RunAs"`
    if chocolatey is installed a lazy sysadmin could also simply run:
    `choco install powershellhere`
  2. lucianovalenca created this gist Dec 28, 2020.
    21 changes: 21 additions & 0 deletions open
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    After checking multiple tutorials I had to take pieces from each of the following to get this to work on my Win10 system:

    * https://www.howtogeek.com/165268/how-to-add-open-powershell-here-to-the-context-menu-in-windows/
    * https://www.tenforums.com/tutorials/60175-open-powershell-window-here-context-menu-add-windows-10-a.html

    Basically it uses the steps from the first article, but under the `background` path from the second article.
    Neither article on its own worked for me.

    Steps:

    1. Open regedit and go to path `HKEY_CLASSES_ROOT\Directory\background\shell`.
    2. Create new key `powershellmenu`.
    3. Change the `Default` value of the `powershellmenu` key to *Open in PowerShell*. (or whatever)
    4. Create new key `command` under `powershellmenu`.
    5. Change the `Default` value of the `command` key to:

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

    6. Right-click on `powershellmenu` key and select `Permissions`, then set permissions to `Full control` for the Administrators group. (or whatever group/user)

    Then try right-clicking in some folder and it should work.