简体   繁体   中英

Executing a .exe file from PowerShell and waiting until all child processes are complete

My co-worker and I were sort of stumped on this. In a last ditch effort to 'try everything' I ran this:

  cmd /c --% ""C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" update --passive --norestart --installpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"

Notice the mismatched double quotes at the start. This ended up doing exactly what we wanted. Does anyone know why this works?

Powershell is looking at your input as one giant string. I'm pretty sure it just ignores one of the double quotes, part of this is due to the --% at the beginning of your statement. You can check out this answer that focuses on the --% portion of your input and how it could be playing a role in what you saw.

Using --% in PowerShell

Putting this here as it is too long for a normal comment. As a follow on to JakeOfSpade helpful answer, the are well document articles on running external stuff using PowerShell. See these

Using PowerShell and external commands and their parameters or switches.

Running external commands, always require special consideration.

PowerShell: Running Executables

Solve Problems with External Command Lines in PowerShell

Top 5 tips for running external commands in Powershell

Using Windows PowerShell to run old command-line tools (and their weirdest parameters)

Execution of external commands in PowerShell done right

Part 2

Part 3

And this one

Of course...

Quoting specifics

... matters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM