简体   繁体   English

将响应文件传递到Powershell中的进程

[英]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.

相关问题 通过启动进程传递变量的Powershell问题 - Powershell Problem with passing Variables through Start-Process 将参数从批处理文件传递到PowerShell - Passing parameters from batch file to PowerShell 将 Powershell 变量传递给 Windows 批处理文件 - Passing Powershell variable to Windows Batch file Powershell - “该进程无法访问该文件,因为它正被另一个进程使用” - Powershell - "The process cannot access the file because it is being used by another process" 批处理文件或Powershell:如何终止特定用户的所有进程 - Batch file or Powershell: How to Kill all Process from a particular user 使用Win32 / MFC将文件位置传递到外部进程 - Passing a file location to an external process using Win32/MFC Powershell CreateFromDirectory进程无法访问文件,因为它正在被另一个进程使用 - Powershell CreateFromDirectory Process cannot access file because it is being used by another process 如何避免错误 inline PowerShell script 进程无法访问该文件,因为它正被另一个进程使用? - How can avoid an error inline PowerShell script The process cannot access the file because it is being used by another process? 设置内容错误:该进程无法访问该文件,因为该文件正在被另一个进程使用(Powershell) - Set-Content Error : The process cannot access the file because it is being used by another process (Powershell) 在PowerShell中进程的状态 - status of the process in powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM