Installing a Microsoft Visual C++ Redistributable with fewer errors

If you just install the Redistributable like this:

    Write-ADTLogEntry "Installing Microsoft Visual C++ 2017 Redistributable (x64) - 14.32.31326..."
    [String]$AppExeName = "$($adtSession.dirFiles)\Redist\VC_redist.x64.exe"
    [String]$AppExeArgs = "/quiet /norestart"
    Start-ADTProcess -FilePath $AppExeName -ArgumentList $AppExeArgs
  • If the existing version is lower, your Redistributable installs the will upgrade the existing version.
  • But, your Redistributable's version is lower than the existing version, the installer will return Error 1638 and fail the whole package.
  • BTW: Error 1638 means Already installed.

.
Here, we tell Start-ADTProcess that Error 1638 is OK and we log when this condition occurs:

    Write-ADTLogEntry "Installing Microsoft Visual C++ 2017 Redistributable (x64) - 14.32.31326..."
    [String]$AppExeName = "$($adtSession.dirFiles)\Redist\VC_redist.x64.exe"
    [String]$AppExeArgs = "/quiet /norestart"
    Remove-Variable Result -ErrorAction SilentlyContinue
    $Result = Start-ADTProcess -FilePath $AppExeName -ArgumentList $AppExeArgs -SuccessExitCodes 0, 1638  -PassThru -ErrorAction SilentlyContinue
    #CAVEAT: using -ExitOnProcessFailure will prevent -PassThru from returning values
    if ($Result.ExitCode -eq 1638)
    {   #MSI Error 1638: Another Version Already Installed
        Write-ADTLogEntry "Detected version higher than 14.32.31326, unable to install VC_redist_14.32.31326_x64" -Severity 2
        Write-ADTLogEntry "Continuing to install the rest of ]$($adtSession.installName)]"
    }

#Here is the PSADT log file when the "error 1638" occurs:

[2026-01-29T18:01:04.4047874-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: Installing Microsoft Visual C++ 2017 Redistributable (x64) - 14.32.31326...
[2026-01-29T18:01:04.6555490-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: Preparing to execute process
[Z:\Local_Source\MY_WIP\FileMaker\FileMakerPro_v22r1\Files\Redist\VC_redist.x64.exe]...
[2026-01-29T18:01:04.6814646-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: CreateNoWindow not specified, StdOut/StdErr streams will not be available.
[2026-01-29T18:01:04.7649736-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: Working Directory is [Z:\Local_Source\MY_WIP\FileMaker\FileMakerPro_v22r1\Files\Redist].
[2026-01-29T18:01:04.8544973-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: Executing ["Z:\Local_Source\MY_WIP\FileMaker\FileMakerPro_v22r1\Files\Redist\VC_redist.x64.exe"
/quiet /norestart]...
[2026-01-29T18:01:07.7961258-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: Executed ["Z:\Local_Source\MY_WIP\FileMaker\FileMakerPro_v22r1\Files\Redist\VC_redist.x64.exe"
/quiet /norestart], awaiting completion...
[2026-01-29T18:01:08.6718161-05:00] [Install] [FileMakerPro_v22r1.ps1] [Success] :: Execution completed successfully with exit code [1638].
[2026-01-29T18:01:08.8153295-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: PassThru parameter specified, returning execution results object.
[2026-01-29T18:01:08.8288587-05:00] [Install] [FileMakerPro_v22r1.ps1] [Warning] :: Detected version higher than 14.32.31326, unable to install VC_redist_14.32.31326_x64
[2026-01-29T18:01:08.8468594-05:00] [Install] [FileMakerPro_v22r1.ps1] [Info] :: Continuing to install the rest of ]FileMakerPro_v22r1]

=====

Why not just detect the existing version?

  • Where to look in the registry changes with each type and version of the Redistributable.
  • You have to know how to code the logic to handle most situations.
  • This method uses the Redistributable's OWN logic and handles just one additional scenario.
  • We log when a higher version already exists for troubleshooting because some applications cannot handle higher versions.
2 Likes