Friday, November 12, 2010

MSIEXEC in Multiple Languages

No, not Latin or Swahili.  Enjoy…

# powershell example

write-host "info: installing CatSkinner2010..."
$cmd = "/i \\server\share\folder\CatSkinner2010.msi /quiet /norestart"
$result = (Start-Process -FilePath "msiexec.exe" -ArgumentList $cmd -Wait -Passthru).ExitCode
if ($result -ne 0) {
write-host "error: exit code was "+$result
} else {
write-host "info: success"
}

' vbscript example

wscript.Echo "info: installing CatSkinner2010..."
cmd = "msiexec /i \\server\share\folder\CatSkinner2010.msi /quiet /norestart"
Set oShell = CreateObject("Wscript.Shell")
result = oShell.Run(cmd, 1, True)
If result <> 0 Then
wscript.Echo "error: exist code was " & result
Else
wscript.Echo "info: success"
End If

rem CMD example

msiexec /i \\server\share\folder\CatSkinner2010.msi /quiet /norestart
if not %errorlevel% == 0 (
echo error: exit code was %errorlevel%
) else (
echo info: success
)

; kixtart example

? info: installing CatSkinner2010...
$cmd = "msiexec /i \\server\share\folder\CatSkinner2010.msi /quiet /norestart"
$result = shell $cmd
if @error <> 0
? "error: exit code was "+@error
else
? "info: success"
endif
Post a Comment