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 install, update, or repair the Microsoft Visual C++ Redistributable on Windows devices. The Fileset downloads the latest supported Microsoft VC++ v14 Redistributable installers 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 x86 runtime. On 32-bit Windows, it installs only the x86 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++ Redistributable
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 script in the Fileset:

    • The Fileset contains the following PowerShell script. It checks whether Windows is 64-bit, builds the required installer list, downloads the redistributable installers from Microsoft, runs them silently, accepts success or success-with-reboot exit codes, and removes the temporary installer files.

      # 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_ARCHITECTURE"
      Write-Output "Detected OS is 64-bit: $([Environment]::Is64BitOperatingSystem)"
      
      # Microsoft latest-supported VC++ v14 Redistributable permalink URLs
      $Installers = @()
      
      if ([Environment]::Is64BitOperatingSystem) {
          $Installers += @{
              Name = 'Visual C++ Redistributable x64'
              Url  = 'https://aka.ms/vc14/vc_redist.x64.exe'
              Path = Join-Path $env:TEMP 'vc_redist.x64.exe'
          }
      
          $Installers += @{
              Name = 'Visual C++ Redistributable x86'
              Url  = 'https://aka.ms/vc14/vc_redist.x86.exe'
              Path = Join-Path $env:TEMP 'vc_redist.x86.exe'
          }
      }
      else {
          $Installers += @{
              Name = 'Visual C++ Redistributable x86'
              Url  = 'https://aka.ms/vc14/vc_redist.x86.exe'
              Path = Join-Path $env:TEMP 'vc_redist.x86.exe'
          }
      }
      
      foreach ($Installer in $Installers) {
          Write-Output "Downloading $($Installer.Name) from $($Installer.Url)"
      
          Invoke-WebRequest `
              -Uri $Installer.Url `
              -OutFile $Installer.Path `
              -UseBasicParsing
      
          Write-Output "Installing $($Installer.Name)"
      
          $Process = Start-Process `
              -FilePath $Installer.Path `
              -ArgumentList '/install', '/quiet', '/norestart' `
              -Wait `
              -PassThru
      
          Write-Output "$($Installer.Name) installer exit code: $($Process.ExitCode)"
      
          # 0 = success
          # 3010 = success, reboot required
          if ($Process.ExitCode -notin @(0, 3010)) {
              throw "$($Installer.Name) failed with exit code $($Process.ExitCode)"
          }
      
          Remove-Item -Path $Installer.Path -Force -ErrorAction SilentlyContinue
      }
      
      Write-Output 'Visual C++ Redistributable installation completed successfully.'
      
  3. Associate the Fileset:

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

Notes

  • Microsoft permalink URLs: The script uses Microsoft's latest-supported VC++ v14 Redistributable permalink URLs. In normal use, these links continue to point to the current supported installers, so the Fileset does not need to be edited just to receive the latest supported redistributable.

  • Architecture behavior: The script checks the operating system bitness, not only the PowerShell process architecture. This prevents a 32-bit PowerShell process running on 64-bit Windows from causing the wrong installer set to be used.

  • Exit 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: The script runs each installer with /install /quiet /norestart. It does not force a reboot, so handle any needed restart through your normal maintenance or deployment process.

  • Network access: Devices must be able to reach Microsoft's aka.ms download URLs when the Fileset activates.