如何在Windows中的文件夹的右键菜单中添加“在此处打开PowerShell”

apc_top

If you’re a fan of using Windows PowerShell rather than the Command Prompt, you might enjoy being able to access it right from the context menu you get when you right-click a folder in Windows. Here’s how to make it happen.

如果您是使用Windows PowerShell而不是命令提示符的爱好者,则可以在右键单击Windows中的文件夹时从获得的上下文菜单中直接访问它。 这是实现它的方法。

Windows already includes an “Open command window here” option when you Shift+click a folder. PowerShell offers a more powerful feature set, though, especially if you do any kind of automation through scripting. If you do prefer PowerShell, you either have to open PowerShell and then navigate to the folder or use the command from the menu in File Explorer. Instead, why not add an “Open PowerShell window here” option to the same context menu? It’s easy to do. You just have to dive into the Windows Registry for a couple of quick edits.

当您按住Shift并单击一个文件夹时,Windows已经包含“此处打开命令窗口”选项。 但是,PowerShell提供了更强大的功能集,尤其是如果您通过脚本执行任何类型的自动化时 。 如果您确实喜欢PowerShell,则必须打开PowerShell,然后导航到该文件夹​​,或者使用“文件资源管理器”菜单中的命令。 相反,为什么不将“此处打开PowerShell窗口”选项添加到同一上下文菜单中呢? 这很容易做到。 您只需深入Windows注册表即可进行一些快速编辑。

通过手动编辑注册表将“此处打开PowerShell窗口”添加到上下文菜单 (Add “Open PowerShell Window Here” to the Context Menu by Editing the Registry Manually)

To add an “Open PowerShell Window Here” option to the context menu, you just need to make a couple of quick edits in the Windows Registry.

要将“此处打开PowerShell窗口”选项添加到上下文菜单,您只需要在Windows注册表中进行几次快速编辑。

Standard warning: Registry Editor is a powerful tool and misusing it can render your system unstable or even inoperable. This is a pretty simple hack and as long as you stick to the instructions, you shouldn’t have any problems. That said, if you’ve never worked with it before, consider reading about how to use the Registry Editor before you get started. And definitely back up the Registry (and your computer!) before making changes.

标准警告:注册表编辑器是一个功能强大的工具,滥用它会使您的系统不稳定甚至无法运行。 这是一个非常简单的技巧,只要您按照说明进行操作,就不会有任何问题。 也就是说,如果您以前从未使用过它,请在开始之前考虑阅读有关如何使用注册表编辑器的信息 。 并在进行更改之前一定要备份注册表 (和您的计算机 !)。

Open the Registry Editor by hitting Start and then typing “regedit.” Press Enter to open Registry Editor and give it permission to make changes to your PC.

通过单击开始,然后键入“ regedit”,打开注册表编辑器。 按Enter键打开注册表编辑器,并授予其对PC进行更改的权限。

own_1

In the Registry Editor, use the left sidebar to navigate to the following key:

在注册表编辑器中,使用左侧边栏导航至以下键:

HKEY_CLASSES_ROOT\Directory\shell
apc_2

Next, you’ll create a new key inside the shell key. Right-click the shell key and choose New > Key. Name the new key “powershellmenu.” We’re naming our new key powershellmenu because in Windows 8 and 10 (and as you can see in our screenshot), a Powershell key already exists that serves other functions.

接下来,您将在shell键中创建一个新键。 右键单击shell密钥,然后选择“新建”>“密钥”。 将新键命名为“ powershellmenu”。 我们之所以命名为新的powershell菜单键,是因为在Windows 8和10中(如您在屏幕截图中所见),已经存在一个Powershell键,该键可用于其他功能。

apc_3

Now, you’ll change the (Default) value inside the new powershellmenu key. With the powershellmenu key selected, double-click the (Default) value to open its properties window.

现在,您将在新的powershellmenu键中更改(Default)值。 选择powershellmenu键后,双击(Default)值以打开其属性窗口。

apc_4

In the properties window, set the value in the “Value data” box to “Open PowerShell Here” and then click “OK.” This gives the command the name that will appear on the context menu.

在属性窗口中,将“值数据”框中的值设置为“在此处打开PowerShell”,然后单击“确定”。 这为命令提供了将出现在上下文菜单中的名称。

apc_5

Optionally, you can also set the command so that it only appears if you hold Shift down while right-clicking a drive—much the same way that the “Open Command Prompt” command is hidden unless you Shift+right-click a folder. To to that, right-click the powershellmenu key and choose New > String Value. Name the new value “Extended.” You don’t need to make any changes to it. Just having that string there will cause the command to be hidden behind Shift key access.

(可选)您还可以设置命令,使其仅在右键单击驱动器时按住Shift键时才显示-与隐藏“打开命令提示符”命令的方式相同,除非您按住Shift键并右键单击文件夹。 为此,右键单击powershellmenu键,然后选择“新建”>“字符串值”。 将新值命名为“扩展”。 您无需对其进行任何更改。 仅在其中具有该字符串将导致命令隐藏在Shift键访问之后。

apc_6

Whether you took the optional step of creating the Extended value or not, the rest of the process is the same. You’ll next need to create a new key inside your powershellmenu key. Right-click the powershellmenu key and choose New > Key. Name the new key “command.”

无论您是否采取了创建Extended值的可选步骤,其余过程都是相同的。 接下来,您需要在powershellmenu密钥内创建一个新密钥。 右键单击powershellmenu键,然后选择“新建”>“键”。 将新键命名为“命令”。

apc_7

Now, you’ll change the  (Default) value inside the new command key. With the command key selected, double-click the (Default) value to open its properties window.

现在,您将在新command键内更改(Default)值。 选择command键后,双击(Default)值以打开其属性窗口。

apc_8

The (Default) value specifies the actual command that will run when you select the option on the context menu. Type the following text into the “Value data” box and then click “OK.”

(Default)值指定在上下文菜单中选择选项时将运行的实际命令。 在“值数据”框中键入以下文本,然后单击“确定”。

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

The changes should take place immediately, so you can exit out of Registry Editor. To test it out, just right-click (or Shift+right-click if you set up that option) any folder and make choose the ”Open with PowerShell” command.

更改应立即进行,因此您可以退出注册表编辑器。 要对其进行测试,只需右键单击(或在设置该选项的情况下按Shift +右键单击)任何文件夹,然后选择“使用PowerShell打开”命令。

apc_a

The PowerShell window should open immediately and, after a few moments, place you inside the folder you right-clicked.

PowerShell窗口应立即打开,过一会儿,将您置于右键单击的文件夹中。

apc_10

If you want to reverse the changes at any time, just go back into the Registry and delete the powershellmenu key that you created. This will automatically delete any values and other keys you created inside the powershellmenu key and remove the command from your context menu.

如果要随时撤消更改,只需返回注册表并删除您创建的powershellmenu项。 这将自动删除您在powershellmenu键内部创建的所有值和其他键,并从上下文菜单中删除该命令。

下载我们的一键式注册表黑客 (Download Our One-Click Registry Hacks)

apc_11

If you don’t feel like diving into the Registry yourself, we’ve created some registry hacks you can use. The “Add PowerShell to Context Menu” hack adds the PowerShell command to the regular context menu. The “Add PowerShell to Shift Context Menu” adds the PowerShell command to the context menu you get when you use Shift+right-click. And the “Remove PowerShell from Context Menu” removes the command no matter which way you added it. All three hacks are included in the following ZIP file. Double-click the one you want to use and click through the prompts.

如果您不想自己进入注册表,我们已经创建了一些可以使用的注册表黑客。 “将PowerShell添加到上下文菜单” hack将PowerShell命令添加到常规上下文菜单。 “将PowerShell添加到Shift上下文菜单”将PowerShell命令添加到使用Shift +右键单击时获得的上下文菜单。 而且“无论从哪种方式添加命令,“从上下文菜单中删除PowerShell”都将删除命令。 以下ZIP文件中包含所有这三种黑客。 双击您要使用的一个,然后单击提示。

PowerShell Context Menu Hacks

PowerShell上下文菜单黑客

These hacks are really just the powershellmenu key, stripped down to the additional keys and values we talked about in the previous section and then exported to a .REG file. Running the hacks just modifies the value. And if you enjoy fiddling with the Registry, it’s worth taking the time to learn how to make your own Registry hacks.

这些技巧实际上只是powershellmenu密钥,被powershellmenu为我们在上一节中讨论的其他密钥和值,然后导出到.REG文件。 运行hack只是修改了价值。 而且,如果您喜欢使用注册表,则值得花时间学习如何制作自己的注册表黑客

翻译自: https://www.howtogeek.com/165268/how-to-add-open-powershell-here-to-the-context-menu-in-windows/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值