How do I start PowerShell from Windows Explorer?

前端 未结 19 1477
無奈伤痛
無奈伤痛 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:12

    For autohotkey users, heres a snippet I am using

    It opens PowerShell window, when pressing Ctrl-Alt-T. (Tested with Win10)

    If your "active window" is a Windows Explorer -window, then the PowerShell is opened in the current folder. Otherwise, just open PowerShell in some default folder.

    Usage: 1) Install AutoHotkey, and copy paste this into myscript.ahk 2) Replace with path of your choice. 3) Run the script.

    ; Ctrl-Alt-T opens PowerShell in the current folder, if using Windows Explorer. Otherwise, just open the Powershell.
    ^!T::
    if WinActive("ahk_class CabinetWClass") and WinActive("ahk_exe explorer.exe")
    {
        KeyWait Control
        KeyWait Alt
        Send {Ctrl down}l{Ctrl up}
        Send powershell{Enter}
    }
    else
    {
        psScript =
        (
        cd 'C:\'
        ls
        )
        Run "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" -NoExit -Command &{%psScript%}
    }
    return
    

提交回复
热议问题