You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSL2中运行Windows .exe文件失败的问题求助

WSL2中无法运行下载的Windows二进制文件问题

我在WSL2里有一个bash引导脚本,会下载Windows二进制文件(Program.exe),但没法在WSL2中运行它。

已验证以下情况:

  • 主机PowerShell中进入WSL2对应的目录,执行./Program.exe可以正常运行
  • 在WSL2中通过/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe打开PowerShell实例后,运行./Program.exe会报错,错误信息如下:
Program 'Program.exe' failed to run: Incorrect functionAt line:1 char:1
+ ./Program.exe
+ ~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ ./Program.exe
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

我还尝试了多种命令变体,均无效:

  • /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe Invoke-Expression -Command "$(wslpath -w ./Program.exe)"
  • "$(wslpath -m ./Program.exe)" | /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Invoke-Expression
  • /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Start-Process Program.exe
  • /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Start-Process ./Program.exe -Verb runas
  • 其他类似命令

这些命令在主机PowerShell里都能正常运行,但在WSL2中执行全部失败。

补充信息:Program.exe是通过Azure CLI从Azure DevOps流水线拉取的C#应用,用于连接SignalR集线器,无需用户输入,可手动终止;通过文件资源管理器进入WSL2文件夹双击该exe能正常运行,但在WSL2环境中就是无法启动,请问问题出在哪里?


内容的提问来源于stack exchange,提问作者Some Guy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 11:17:33