# 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 Central or FileWave Anywhere**: Required to import, assign, and deploy the Fileset to Windows devices.
- **VC++ Redistributable Fileset**: Download the Fileset using the link below.

<table id="bkmrk-macos" style="border-collapse:collapse;width:19.2593%;"><colgroup><col style="width:100%;"></col></colgroup><tbody><tr><td class="align-center" style="background-color:rgb(206,212,217);">**Windows VC++ Redistributable**</td></tr><tr><td>[![FileWave Download.png](https://kb.filewave.com/uploads/images/gallery/2023-06/scaled-1680-/LhUDCHKqr6dGiaoG-filewave-download.png)](https://kb.filewave.com/attachments/394)</td></tr></tbody></table>

## Directions

1. **Import the Fileset:**
    
    
    - Download the Fileset from the link above.
    - Import the Fileset into FileWave Central or FileWave Anywhere.
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.
        
        ```powershell
        # 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 aka.ms/vc14 links point to the current supported Visual C++ v14 runtime installers.
        # "v14" is Microsoft's runtime family name for Visual Studio 2015 and later supported releases.
        $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-maintained `aka.ms/vc14` download links for the current supported Visual C++ v14 runtime family. In Microsoft's naming, **v14** refers to the Visual C++ runtime generation that started with Visual Studio 2015 and continues through later supported Visual Studio releases. It does not mean the Fileset installs only the original 2015/14.0 redistributable. The links redirect to Microsoft's latest supported installers for that runtime family.
- **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.

## Related Content

- [Microsoft Visual C++ Redistributable Documentation](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170)