在 Windows 终端中启动 `powershell.exe' 时如何修复错误 0x800700c1?

How to fix the error 0x800700c1 when launching `powershell.exe' in Windows Terminal?

最近我的 Windows 终端出现以下错误:

[error 0x800700c1 when launching "C:\Users\Dry-C Desktop\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe"]

How do Image of the Issue - error 0x800700c1

我怎么想知道,我该如何解决才能解决这个问题?

我通过添加以下内容更改 Windows Terminal settings.json 配置文件解决了这个问题:

1 - 查找设置: Windows 选项卡附近的 arrow down 终端,单击 settings button,然后单击 Open JSON File 字段。

2 - 将此命令添加到配置文件中,如下例所示:

"commandline": "\"C:\Users\Your Machine actual Username\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe\""

Windows Terminal配置:

{
   ...
   "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
   "hidden": false,
   "name": "PowerShell",
   "source": "Windows.Terminal.PowershellCore",
},
...

更改后:

{
   ...
   "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
   "hidden": false,
   "name": "PowerShell",
   "source": "Windows.Terminal.PowershellCore",
   "commandline": "\"C:\Users\Your Machine actual Username\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe\"",
},
...

不要忘记在 commandline 字段中更改 You Machine Actual Username

参考:https://github.com/microsoft/terminal/issues/6082#issuecomment-1001226003

或者您也可以遵循这个同样有效的博客建议: https://blog.darrenjrobinson.com/error-0x800700c1-when-launching-cprogram-filespowershell7pwsh-exe/