Windows PowerShell无法运行及VS Code终端无法打开问题求助
针对你遇到的64位PowerShell报错、VS Code终端无法启动(仅x86版PowerShell正常)的问题,结合你已尝试的修复手段,给出以下针对性方案:
检查并修复64位PowerShell执行策略
打开正常的x86版PowerShell(管理员权限),执行命令:Get-ExecutionPolicy -List查看
LocalMachine或CurrentUser层级的64位执行策略是否被设为Restricted。如果是,执行:Set-ExecutionPolicy RemoteSigned -Scope LocalMachine按提示确认修改后,尝试启动64位PowerShell。
修复PowerShell注册表项
打开注册表编辑器(regedit),定位到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell,确认ExecutionPolicy键值为RemoteSigned;同时对比HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell(x86版注册表项),确保64位路径下的注册表项无缺失或异常。重置VS Code终端配置
- 打开VS Code,按下
Ctrl+Shift+P打开命令面板,输入Terminal: Select Default Profile,选择Windows PowerShell(64位版本,路径为C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)。 - 再次打开命令面板,输入
Terminal: Reset Terminal,重启终端测试。 - 若仍有问题,打开VS Code设置(
Ctrl+,),搜索terminal.integrated.profiles.windows,手动确认PowerShell的路径指向64位可执行文件,而非x86的C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe。
- 打开VS Code,按下
重新注册64位PowerShell组件
在管理员权限的x86版PowerShell中执行以下命令,重新注册64位PowerShell的应用包:%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy RemoteSigned -Command "Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"执行完成后重启设备,测试64位PowerShell和VS Code终端。
卸载近期Windows更新
既然推测问题由Windows更新导致,可尝试卸载两个月后安装的更新:- 打开Windows设置→Windows更新→更新历史记录→卸载更新。
- 找到最近安装的KB系列更新,逐个卸载后重启设备,测试问题是否解决。
内容的提问来源于stack exchange,提问作者cell

