How do I start PowerShell from Windows Explorer?

前端 未结 19 1475
無奈伤痛
無奈伤痛 2020-12-04 04:24

Is there a way to start PowerShell in a specific folder from Windows Explorer, e.g. to right-click in a folder and have an option like \"Open PowerShell in this Folder\"?

19条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 05:13

    The following is a concise (and updated) summation of the earlier solutions. Here's what to do:

    Add these strings and their respective parent keys:

    pwrshell\(Default) < Open PowerShell Here
    pwrshell\command\(Default) < powershell -NoExit -Command Set-Location -LiteralPath '%V'
    pwrshelladmin\(Default) < Open PowerShell (Admin)
    pwrshelladmin\command\(Default) < powershell -Command Start-Process -verb runAs -ArgumentList '-NoExit','cd','%V' powershell
    

    at these locations

    HKCR\Directory\shell (for folders)
    HKCR\Directory\Background\shell (Explorer window)
    HKCR\Drive\shell (for root drives)
    

    That's it. Add the "Extended" strings for the commands only to be visible if you hold the "Shift" key, everything else is superfluous.

提交回复
热议问题