将响应文件传递给 Powershell 中的进程
Passing a response file to a process in Powershell
我有一个传统上是 运行 的过程(在命令行中):
filepath.exe@"respfile.resp"
其中 respfile.resp 是一个响应文件,其中包含可执行文件的命令行参数。
运行 这样的命令在命令提示符中按预期工作。
但是我正在尝试使用 powershell 脚本 运行 多个程序。这是我拥有的:
if (Test-Path $respPath){
$executionResposne = Start-Process -NoNewWindow -Wait -PassThru -FilePath $bimlcExePath -ArgumentList $respPath
if ($executionResposne.ExitCode -eq 1){
Write-Output "Unable to successfully run the process. Exiting program."
return
}
}
我收到以下错误消息:
Error:: filepath\to\resp\file Data at the root level is invalid.
我怎样才能使这个工作?
您需要为解释器嵌入引号:
-ArgumentList "@`"$respPath`""
我有一个传统上是 运行 的过程(在命令行中):
filepath.exe@"respfile.resp"
其中 respfile.resp 是一个响应文件,其中包含可执行文件的命令行参数。
运行 这样的命令在命令提示符中按预期工作。
但是我正在尝试使用 powershell 脚本 运行 多个程序。这是我拥有的:
if (Test-Path $respPath){
$executionResposne = Start-Process -NoNewWindow -Wait -PassThru -FilePath $bimlcExePath -ArgumentList $respPath
if ($executionResposne.ExitCode -eq 1){
Write-Output "Unable to successfully run the process. Exiting program."
return
}
}
我收到以下错误消息:
Error:: filepath\to\resp\file Data at the root level is invalid.
我怎样才能使这个工作?
您需要为解释器嵌入引号:
-ArgumentList "@`"$respPath`""