powershell - 安装 VS Code 后从文件资源管理器执行 Powershell

标签 powershell visual-studio-code windows-explorer

VS Code 试图将自己定位为一种使用 Powershell 的新方式,它在安装时所做的更改之一是将 .ps1 文件上的文件资源管理器上下文菜单选项“使用 PowerShell 运行”替换为新的“请改为使用“代码打开”选项。

有没有办法删除“使用代码打开”选项并将其替换为旧的“使用 PowerShell 运行”选项?我认为这会以某种方式涉及注册表,但我通常对注册表了解不够,无法安全地完成此操作。

最佳答案

试试这个:

将以下内容保存到文件“EnablePowerShellRightClickRun.reg”中,然后右键单击 - 合并。

然后,将 .ps1 文件与哪个应用程序关联并不重要 - 您仍然可以使用“使用 Powershell 运行”作为右键单击选项。

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1]

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\shell]

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\shell\RunPS]
@="Run with Powershell"

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\shell\RunPS\command]
@="\"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\" -File \"%1\""

关于powershell - 安装 VS Code 后从文件资源管理器执行 Powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47685752/

相关文章:

powershell - 如何跳过CSV文件中的第一行

powershell - 在 PowerShell 版本 2 中将字符串转换为字节数组

typescript - VSCode Typescript 语法突出显示中类型的标记名称是什么?

c# - 在 VS Code : Getting scriptcs error 中运行 C# 代码时遇到问题

java - 无法在 Visual Studio Code 中运行 java 代码

icons - 有没有办法让 ClearCase 在 Windows 资源管理器中显示图标来表示文件/目录的状态?

regex - 带有命名组的替换字符串中的 Powershell 变量

Powershell - Windows Server 2008 的 Sku

windows-7 - Windows 资源管理器错误消息?

batch-file - 将包含许多文件的文件夹拆分为多个子文件夹 (Windows 10)