看来我可以使用单引号或双引号转义命令行参数:
PS C:\> echo Hello World
Hello
World
PS C:\> echo 'Hello World'
Hello World
PS C:\> echo "Hello World"
Hello World
但还有一件事我无法弄清楚,那就是当您希望从包含空格的目录运行可执行文件时:
PS C:\> c:\program files\test.exe
The term 'c:\program' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
At line:1 char:11
+ c:\program <<<< files\test.exe
PS C:\> 'c:\program files\test.exe'
c:\program files\test.exe
PS C:\> "c:\program files\test.exe"
c:\program files\test.exe
PS C:\>
如何让 PowerShell 运行上面的可执行文件?
尝试在命令前添加一个 & 符号。例如
& 'C:\Program Files\winscp\winscp.exe'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)