简体   繁体   中英

Powershell command did not wait

I have following 2 commands in powershell script file, but second command did not wait till first command gets executed.

cmd.exe /c "msiexec /i c:\Temp\mysql.msi /quiet" 
cd "C:\Program Files (x86)\MySQL\MySQL Installer for Windows"

note: first command installing mysql installer at location C:\\Program Files (x86)\\MySQL\\MySQL Installer for Windows"... In second command, i used cd to go to at directory C:\\Program Files (x86)\\MySQL\\MySQL Installer for Windows"

Your PowerShell script does not know what the cmd.exe command is going to execute but it does wait for cmd.exe to finish.

The problem is that cmd.exe is not waiting for msiexec before returning.

If you wish to wait for msiexec to finish before moving on to your second command then call msiexec yourself using Start-Process with the -Wait parameter:

Start-Process -Wait -FilePath msiexec -ArgumentList "/i c:\Temp\mysql.msi /quiet"

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