Forum Discussion
Installing multiple MSI's
Just want to get a full understanding of what you mean, as mine works the way the OP provided. Granted I wouldn't do it this way, but while we are on the subject lol.
Doing it this way both of my executables started. I may be missing a detail, but sounds like you are saying it doesn't or shouldn't work with msiexec.exe?
Start-Process msiexec.exe -argumentlist '-i "C:\Users\%username%\Desktop\VNC Server 6.4.1 x64.msi" /qr /promptrestart /lv "C:Test.log" ' -wait
Start-Process msiexec.exe -ArgumentList '-i "C:\Users\%username%\Desktop\VNC Viewer 6.19.325 x64.msi" /qr /promptrestart /lv "C:Test.log"'
pause
Thanks!
Wait is a directive to the hosting process to actively poll the process it created and not exit until the child process has indicated it has exited.
Not using the wait method results in the calling process starting the new process and exiting immediately. This is why cmd.exe has the "/c" parameter, the "start" command has the "/wait" parameter and Start-Process has the "-Wait" parameter, to name some examples.
Using .NET as the reference point, this equates to the functionality described in the WaitForExitAsync() method (usually - there's variations.)
Calling from an ongoing process such as a console shell often works where calling from inside other hosts like the task scheduler environment or even the "Run" box within the Windows Start menu can yield early which results in processes terminating early. Which is why they supply some form of "wait" option as a means for receiving such a directive.
So, it's not a one-size-fits all answer since it depends on your starting point but my guess is that those commands are executing in something other than a persistent shell. I'm basing that on the statement that first command leverages the "wait" and works while the second does not.
Process.WaitForExitAsync(CancellationToken) Method (System.Diagnostics) | Microsoft Docs
The .NET reference is just for further reading if you're interested. The concept is old and has nothing to do with .NET.
Cheers,
Lain
- LeaviiApr 01, 2022Brass Contributor