2

We are tying to install an MSI file on Windows servers using the following script and are able to install the MSI file in a Windows server. The Following code IS working fine for some MSI files, but it's failing for others. getting exit-code as 1603. If we do clean installation it works fine, but while trying to reinstall, we are getting an exit-code:1603 error. All the configuration settings are same for all services.

As mentioned on the Microsoft web site, we verified that following conditions and none are applied to our case.

  • Windows Installer is attempting to install an app that is already installed on your PC.

  • The folder that you are trying to install the Windows Installer package to is encrypted.

  • The drive that contains the folder that you are trying to install the Windows Installer package to is accessed as a substitute drive.

  • The SYSTEM account does not have Full Control permissions on the folder that you are trying to install the Windows Installer package to. You notice the error message because the Windows Installer service uses the SYSTEM account to install software.

Code:

:outer for($i=1; $i -le $attempts; $i++) {
    $timeout = $null
    $proc = Start-Process -filePath $InstallerPath -ArgumentList $InstallCommand -PassThru
    $proc | Wait-Process -Timeout $SecondsToWait -ea 0 -ev timeout
    If (($timeout) -or ($proc.ExitCode -ne 0)) {
        $proc | kill
        $error = "`tFailed To Run $($ProcessTitle)Operations: Exit-Code = $($proc.ExitCode)"
        If(($i+1) -le $attempts) {
            WriteLog -Message($error) -MainLoggingConfigs $MainLoggingConfigs
            Start-Sleep -s $WaitTimePerAttempt
        }
        Else {
            throw $error
        }
    }
    Else {
        break outer
    }
1
  • -filePath $InstallerPath -ArgumentList $InstallCommand the values for $InstallerPath and $InstallComand will help for an answer Commented Nov 9, 2020 at 16:16

1 Answer 1

6

If using an MSI, you'll want to use Start-Process msiexec.exe -wait -NoNewWindow instead of Wait-Process . If you are really worried about it running forever, consider using PowerShell jobs:

Start-Job -Name MyInstall -scriptBlock {
    Start-Process msiexec.exe -NoNewWindow -ArgumentList $MSIArguments
}
Wait-Job -Name MyInstall

Then check the job Get-Job MyInstall for output, status messages, state, errors, and especially child jobs.

The error you get may be due to competing installation attempts if your Start-Process creates child processes that haven't ended. Try out using something like Kevin Marquette's solution to save off the verbose MSI logs as well:

$MSI = 'C:\path\to\msi.msi'
$DateStamp = get-date -Format yyyyMMddTHHmmss
$logFile = "$MSI-$DateStamp.log"
$MSIArguments = @(
    "/i"
    "`"$MSI`""
    "/qn"
    "/norestart"
    "/L*v"
    $logFile
)
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your time and response. I implement your suggestions and give it a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.