powershell无法调用Path中Program Files (x86)下的程序

查看:769
本文介绍了powershell无法调用Path中Program Files (x86)下的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

在Path环境变量加入一个在Program Files (x86)下的路径后,Get-Command可以正常直接获取该路径下的程序,但执行时会因为路径里的x86而报错。如下所示:

C:\> (Get-Command code).Source
C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd
C:\> code
警告: Could not find ssh-agent
x86 : 无法将x86项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果
包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 19
+ C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd
+                   ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

C:\> $env:PATH
C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program File
s\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\Syste
m32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Component
s\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)
\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management E
ngine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\
Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\system32;C:\WI
NDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\n
odejs\;C:\Program Files (x86)\scala\bin;C:\Program Files\TortoiseGit\bin;C:\WINDOWS\system32\
config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Win
dows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Bi
nn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Users\D
ustar\AppData\Local\Microsoft\WindowsApps;C:\Users\Dustar\AppData\Roaming\npm;C:\Program File
s (x86)\Microsoft VS Code\bin
C:\>

这个问题在cmd里并不会出现。
请问这是什么原因,该怎么解决?

解决方案

后来找到原因是把环境变量里的ComSpec改成powershell就会出这个问题

这篇关于powershell无法调用Path中Program Files (x86)下的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆