Executing an EXE file using a PowerShell script

前端 未结 5 1930
粉色の甜心
粉色の甜心 2020-11-29 20:30

I\'m trying to execute an EXE file using a PowerShell script. If I use the command line it works without a problem (first I supply the name of the executable and series of p

5条回答
  •  失恋的感觉
    2020-11-29 21:21

    It looks like you're specifying both the EXE and its first argument in a single string e.g; '"C:\Program Files\Automated QA\TestExecute 8\Bin\TestExecute.exe" C:\temp\TestProject1\TestProject1.pjs /run /exit /SilentMode'. This won't work. In general you invoke a native command that has a space in its path like so:

    & "c:\some path with spaces\foo.exe" 
    

    That is & expects to be followed by a string that identifies a command: cmdlet, function, native exe relative or absolute path.

    Once you get just this working:

    & "c:\some path with spaces\foo.exe"
    

    Start working on quoting of the arguments as necessary. Although it looks like your arguments should be just fine (no spaces, no other special characters interpreted by PowerShell).

提交回复
热议问题