Skip to main content

Upgrading or Repairing the Visual C++ Redistributable on Windows (Windows script)

Description

This article describes how to use the attached FileWave Fileset to installinstall, update, or updaterepair the Microsoft Visual C++ Redistributable (VC++).on Windows devices. The provided Fileset ensures thatdownloads the appropriatelatest versionsupported ofMicrosoft VC++ isv14 installedRedistributable basedinstallers directly from Microsoft and runs them silently.

On 64-bit Windows, the script installs both the x64 and x86 redistributables because many 32-bit applications still depend on the processorx86 architectureruntime. (AMD64,On ARM64,32-bit orWindows, x86)it ofinstalls only the device.x86 The script included in the Fileset automatically downloads the correct VC++ installer from Microsoft, installs it, and then performs cleanup.redistributable.

Ingredients

  • FileWave Admin: Required to import and deploy the Fileset to Windows devices.

  • VC++ Redistributable Fileset: Download the Fileset using the link below.

Windows VC++ v17Redistributable
FileWave Download.png

Directions

  1. Import the Fileset:

    • Download the Fileset from the link above.

    • Import the Fileset into the FileWave Admin console.

  2. Review the Scriptscript in the Fileset:

    • The Fileset contains the following PowerShell scriptscript. thatIt determineschecks whether Windows is 64-bit, builds the systemrequired architecture,installer list, downloads the appropriateredistributable versioninstallers offrom VC++,Microsoft, installsruns it,them silently, accepts success or success-with-reboot exit codes, and cleans upremoves the temporary installer files.

      echo# Installs the latest supported Microsoft Visual C++ Redistributable.
      # On 64-bit Windows, this installs both x64 and x86 because many 32-bit apps still require the x86 runtime.
      # On 32-bit Windows, this installs only x86.
      
      $ErrorActionPreference = 'Stop'
      
      Write-Output "Detected PowerShell process architecture: $env:PROCESSOR_ARCHITECTUREPROCESSOR_ARCHITECTURE"
      Write-Output "Detected OS is 64-bit: $([Environment]::Is64BitOperatingSystem)"
      
      # DetermineMicrosoft processorlatest-supported architectureVC++ v14 Redistributable permalink URLs
      $ArchitectureInstallers = $env:PROCESSOR_ARCHITECTURE@()
      
      if ($Architecture -eq 'AMD64')[Environment]::Is64BitOperatingSystem) {
          $InstallerUrlInstallers += @{
              Name = 'Visual C++ Redistributable x64'
              Url  = 'https://aka.ms/vs/17/release/vc14/vc_redist.x64.exe'
              Path = Join-Path $env:TEMP 'vc_redist.x64.exe'
          }
      
          elseif$Installers ($Architecture+= -eq@{
              Name = 'ARM64')Visual {C++ $InstallerUrlRedistributable x86'
              Url  = 'https://aka.ms/vs/17/release/vc14/vc_redist.arm64.x86.exe'
              Path = Join-Path $env:TEMP 'vc_redist.x86.exe'
          }
      }
      else {
          $InstallerUrlInstallers += @{
              Name = 'Visual C++ Redistributable x86'
              Url  = 'https://aka.ms/vs/17/release/vc14/vc_redist.x86.exe'
              Path = Join-Path $env:TEMP 'vc_redist.x86.exe'
          }
      echo}
      
      foreach ($Installer in $InstallerUrlInstallers) #{
          DownloadWrite-Output installer"Downloading $InstallerPath($Installer.Name) =from $($Installer.Url)"$env:TEMP\vc_redist.exe"
      
          Invoke-WebRequest `
              -Uri $InstallerUrlInstaller.Url `
              -OutFile $InstallerPathInstaller.Path #`
              Install-UseBasicParsing
      
          VisualWrite-Output C++"Installing redistributable$($Installer.Name)"
      
          $Process = Start-Process `
              -FilePath $InstallerPathInstaller.Path `
              -ArgumentList '/install', '/passive'quiet', '/norestart' `
              -Wait `
              -PassThru
      
          Write-Output "$($Installer.Name) installer exit code: $($Process.ExitCode)"
      
          # Clean0 up= success
          # 3010 = success, reboot required
          if ($Process.ExitCode -notin @(0, 3010)) {
              throw "$($Installer.Name) failed with exit code $($Process.ExitCode)"
          }
      
          Remove-Item -Path $InstallerPathInstaller.Path -Force -ErrorAction SilentlyContinue
      }
      
      Write-Output 'Visual C++ Redistributable installation completed successfully.'
      
  3. Associate the Fileset:

    • Assign the Fileset to the relevant Windows devices where VC+the Visual C++ Redistributable needs to be installedinstalled, updated, or updated.repaired.

Notes

  • Customizations:Microsoft permalink URLs: IfThe ascript neweruses versionMicrosoft's oflatest-supported VC++ isv14 required,Redistributable youpermalink canURLs. updateIn thenormal URLsuse, inthese thelinks scriptcontinue to point to the current supported installers, so the Fileset does not need to be edited just to receive the latest Microsoftsupported Visual C++ Redistributable version.redistributable.

  • Architecture Detection:behavior: The script handleschecks commonthe architecturesoperating likesystem AMD64,bitness, ARM64,not andonly x86,the whichPowerShell areprocess automaticallyarchitecture. detectedThis andprevents useda 32-bit PowerShell process running on 64-bit Windows from causing the wrong installer set to downloadbe theused.

    appropriate
version of

Exit VC++.codes: The Microsoft installer exit code 0 is treated as success. Exit code 3010 is also treated as success, but it means Windows reports that a reboot is required.

Silent Installation:installation: The script installsruns VC++each ininstaller passivewith mode/install without/quiet user/norestart. interactionIt anddoes suppressesnot force a reboot.reboot, Ifso youhandle needany aneeded differentrestart installationthrough behavior,your modifynormal maintenance or deployment process.

Network access: Devices must be able to reach Microsoft's aka.ms download URLs when the argumentFileset list in the Start-Process command.activates.