将 Powershell 命令添加到文件夹上和文件夹中的右键单击菜单

Sdd*_*ddS 6 windows-registry windows-7 powershell context-menu

网上有一些解决方案,但大多数只是在您右键单击文件夹时添加命令。我已经找到以管理员身份运行的解决方案(其工作两者)在这里。但它仅适用于管理员访问。

Sdd*_*ddS 8

这是解决方案:

这将 powershell 添加到打开窗口(即右键单击文件时)

[HKEY_CLASSES_ROOT\Directory\shell]
    1. Create a key such as "powershell" or whatever you want without space
    2. Set the default value of the key as your desired text, e.g.:"PS here dear"
    3. Create a nested key inside the "powershell" key as "command"
    4. Edit the command value by this:
        C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -NoProfile -Command Set-Location -LiteralPath '%L'
Run Code Online (Sandbox Code Playgroud)

这将 powershell 添加到文件夹内的右键菜单

[HKEY_CLASSES_ROOT\Directory\Background\shell]
    1. Create a key such as "powershell" or whatever you want withuout space
    2. Set the default value of the key as your desired text e.g "PS here dear"
    3. Create a nested key inside the "powershell" key as "command"
    4. Edit the command value by this:
        C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -NoProfile -Command Set-Location -LiteralPath '%V'
Run Code Online (Sandbox Code Playgroud)

注意命令中的 %V 和 %L 差异