0

我正在尝试使用空格启动 powershell 进程,请参见以下示例:

在职的:

$path = "C:\Windows\System32\notepad.exe"
Start-Process -FilePath powershell.exe -ArgumentList "& $path"

不工作(带空格):

$path = "C:\Program Files (x86)\CustomApp\Server.exe"
Start-Process -FilePath powershell.exe -ArgumentList "& $path; Read-Host"

使用Read-Host控制台退出前显示错误消息:术语“x86”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。

我该如何处理空间Start-Process

4

1 回答 1

3

将您的路径也放在单引号中:

$path = "'C:\Program Files (x86)\CustomApp\Server.exe'"
Start-Process -FilePath powershell.exe -ArgumentList "& $path; Read-Host"
于 2019-08-30T12:01:02.223 回答