[英]Passing a response file to a process in Powershell
I have a process that would traditionally be run like so (in the command line): 我有一个传统上会这样运行的过程(在命令行中):
filepath.exe @"respfile.resp" filepath.exe @“ respfile.resp”
where respfile.resp is a response file that has command line arguments for the executable. 其中respfile.resp是具有可执行文件命令行参数的响应文件。
Running the command like that works as desired in the command prompt. 在命令提示符下按需要运行这样的命令。
However I am trying to use a powershell script to run multiple programs. 但是,我试图使用Powershell脚本来运行多个程序。 Here is what I have:
这是我所拥有的:
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
}
}
and I am getting the following error message: 并且我收到以下错误消息:
Error:: filepath\to\resp\file Data at the root level is invalid.
How can I make this work? 我该如何进行这项工作?
您需要嵌入解释器的引号:
-ArgumentList "@`"$respPath`""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.