With BAT/CMD
script I can simply use "msiexec /i <whatever.msi> /quiet /norestart"
and then check %errorlevel%
for the result.
With VBScript
, using the Wscript.Shell
object Run()
method, I can get the result like this:
"result = oShell.Run("msiexec /i ...", 1, True)"
How can I do this with PowerShell?
or
depending on what you're after. The former is an integer, the latter just a boolean. Furthermore,
$LastExitCode
is only populated for native programs being run, while$?
generally tells whether the last command run was successful or not – so it will also be set for cmdlets.I would wrap that up in Start-Process and use the ExitCode property of the resulting process object. For example
You can also use the powershell app deployment kit which provides several things.
Then you can use for example