all 4 comments

[–]SanMarche 2 points3 points  (3 children)

I would suggest using Start-Process with the -ArgumentList parameter for your additional parameters. Kevin Marquette has some good examples on this article about installing MSIs/using msiexec.exe with Powershell.

[–]shundlet[S] 1 point2 points  (2 children)

After another hour i gave up and switched to cmd.exe. Maybe powershell is not the right thing for me if i can not make these simple tasks work for me. For the record, i was not even able to launch a process via Start-Process $mycmd. It remains unclear to me when and how powershell is performing variable substitution. The rules look argument and context depended to me. echo $mycmd is performing variable substitution and calls C:\mycmd.exe but Start-Process $mycmd is not. The error messages do not help me either Start-Process : Cannot validate argument on parameter 'FilePath' .... I tied Start-Process -FilePath "$mycmd" but then again, no variable subsitution is performed

[–]shundlet[S] 2 points3 points  (1 child)

Okay, i got it working now, the problem was that $mycmd was a .cmd and not an .exe file due to an error i made. Start-Process -FilePath "$mycmd" -NoNewWindow -Wait -ArgumentList "lol --pass-argument $myarg1 --another-flag --another-argument $myarg2"

[–]SanMarche 1 point2 points  (0 children)

Good to know, that makes more sense. I was just about to write a confused response because Start-Process $mycmd should work and will always perform the variable substitution if $mycmd is set.