我希望powershell使用环境变量“PATH”来解析可执行文件。我相信它应该可以做到这一点,但这就是我得到的。
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
PS C:\> ${ENV:PATH} = "C:\WINDOWS\System32\"
PS C:\> ls ${ENV:PATH}\cmd.exe
Directory: C:\WINDOWS\System32
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 22/08/2013 8:03 PM 355840 cmd.exe
PS C:\> & cmd.exe
& : The term 'cmd.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & cmd.exe
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (cmd.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
答案 0 :(得分:5)
运行Get-Command -Type Application
以查看PowerShell看到的有效可执行文件。
您可能会发现所发生的事情的线索,例如所有列出的应用程序都有(或者没有)某个扩展名,这可能表明{{1}有问题环境变量。