Mailbag: How to perform a silent install of the Visual C++ 2010 redistributable packages


Question:

You previously posted lists of command line switches to perform silent and unattended installations of the Visual C++ 2005 redistributable and the Visual C++ 2008 redistributable.  How can I perform silent and unattended installations of the Visual C++ 2010 redistributable?

Answer:

The Visual C++ 2010 redistributable packages (vcredist_x86.exe, vcredist_x64.exe and vcredist_ia64.exe) support the following command line installation options.

The examples below use the file named vcredist_x86.exe, but you can substitute the x64 or ia64 versions of the EXEs with equivalent command lines to achieve the same behavior for them as well.

Silent install

This option will suppress all UI and perform an install.

<full path>\vcredist_x86.exe /q /norestart

For example, if you download vcredist_x86.exe to a folder named c:\vc2010redist, then the command line would look like this:

c:\vc2010redist\vcredist_x86.exe /q /norestart

Unattended install

This option will display a progress dialog (but requires no user interaction) and perform an install.

<full path>\vcredist_x86.exe /passive /norestart

For example, if you download vcredist_x86.exe to a folder named c:\vc2010redist, then the command line would look like this:

c:\vc2010redist\vcredist_x86.exe /passive /norestart

Silent repair

This option will suppress all UI and perform a repair.

<full path>\vcredist_x86.exe /q /repair /norestart

For example, if you download vcredist_x86.exe to a folder named c:\vc2010redist, then the command line would look like this:

c:\vc2010redist\vcredist_x86.exe /q /repair /norestart

Silent uninstall

This option will suppress all UI and perform an uninstall.

<full path>\vcredist_x86.exe /q /uninstall /norestart

For example, if you download vcredist_x86.exe to a folder named c:\vc2010redist, then the command line would look like this:

c:\vc2010redist\vcredist_x86.exe /q /uninstall /norestart

A note about reboots

All of the examples above use the /norestart switch to suppress reboots after the setup process completes.  The /norestart switch does not eliminate the need to reboot entirely – it just gives the calling process control over when to schedule the reboot if one is needed due to files being in use during setup.  If you run the Visual C++ 2010 redistributable setup and use the /norestart switch, you must check the exit code returned by the setup process and handle it accordingly in the calling process.  Here are the possible exit codes:

  • Exit code 0 means that setup succeeded and no reboot is needed.
  • Exit code 3010 means that setup succeeded and a reboot is needed to complete installation.
  • Any other exit code means that setup failed.

Related link

Comments (51)

  1. Daniel Szabo says:

    Thanks for posting this, useful information. On the other hand, if you have the right connections, please let the build engineers know about the idea that the following naming convention might not be the best one: name of vc++ 2005 redist package: vcredist_x86.exe; name of vc++ 2008 redist package: vcredist_x86.exe; name of vc++ 2010 redist package: vcredist_x86.exe.

  2. astebner says:

    Hi Daniel Szabo – I'm not sure I understand your feedback.  Are you suggesting that each version should have a unique name or something like that (vc2005redist_x86.exe, vc2008redist_x86.exe, etc)?  I think the best way to provide that type of feedback would be for you to post a suggestion on the Connect site at connect.microsoft.com/visualstudio.

  3. Daniel Szabo says:

    Hi! Thanks for the link (and yes, unique naming for each release would be great). I will try contacting them (I have other exotic questions to them like why don't they manage to put each new vc++ library into the windows update system but you're right – this has nothing to do with you) Keep up the good posts!

  4. asf says:

    Why should they? VS is not part of windows. Next thing you know Borland/"whatever they are called today" want their runtimes on windows update

  5. Madhur says:

    Thanks Aaron for providing usefull info for installing VC++ 2010, Do we require windows installer for installing redistributable?.

    In the project currently I'm working it installs Windows Installer for installing VC++ 2005 redistributable. I'm not sure for installing VC++ 2010 redistributable MSI requires or not.

  6. astebner says:

    Hi Madhur – All versions of the Visual C++ Redistributable are packaged as .msi files, so they all require a version of Windows Installer in order to be able to install successfully.  The VC++ 2010 Redistributable requires at least Windows Installer 2.0, and that comes as a part of Windows on each of the versions of Windows that the VC++ 2010 Redistributable supports.  As a result, you don't need to worry about installing Windows Installer before trying to install the VC++ 2010 Redistributable.

  7. Madhur says:

    Thanks Aaron!! Actually when we were installing VC8 redistributable that time we installed windows installer 3.1.

    So as per your suggestion we don't have to worry regarding installer.

  8. Madhur says:

    Hi Aaron, Can we know programmatically which specific version of redistributables is used? I mean suppose VC10 RTLs releases a new version in future then how can we read, because "Installed" DWORD under \Software\Microsoft\VisualStudio\10.0\VC\VCRedist\x86 gives whether VC10 Redistributables are installed or not; but not give specific version. Any help is appreciable.

  9. astebner says:

    Hi Madhur – There is a Version value under that registry sub-key, and it has different values for the original release of the Visual C++ Redistributable and for the SP1 beta that is currently available.  You would have to create a custom action to parse this Version registry value though, so if your application requires a specific version of the redistributable, it might be best to check for the install state of that exact redistributable MSI instead of relying on this registry key.  You can do that by using Windows Installer APIs or by checking for the product code under HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionUninstall{productcode}.

  10. Madhur says:

    Thanks Aaron for responding!!

    When I tried to install VCRT 10 at PC that has no VS2010 installation and Windows XP Service Pack 3

    It installs under C:WindowsSystem32 folder and registers under registry. So programmatically checking out at \Software\Microsoft\VisualStudio\10.0\VC\VCRedist\x86 is ruled out.

    When I tried to install at PC where no VS 2010 and SP3 (i.e. WIN XP SP2) then it has given following message

    —————————

    Microsoft Visual C++ 2010  x86 Redistributable Setup

    —————————

    Windows Installer version 3.1 or higher is required to perform this installation. Please visit support.microsoft.com to obtain the appropriate version of Windows Installer 3.1 for your system.

    —————————

    OK  

    —————————

    So, it requires minimum WIN-XP SP3 or WIN-XP SP2 + Windows Installer 3.1 (Minimum) so it will not work with Windows Installer 2.0

    Now my task is to find out whether VC10 RTLs are installed or not

    In VC8 we are checking by whether ATL80.dll exist or not at C:WINDOWSWinSxSx86_Microsoft.VC80.ATL_XXXXXXXXXXATL.dll

    where XXXXXX is Version String e.g.C:WINDOWSWinSxSx86_Microsoft.VC80.ATL_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_6e805841 folder,

    so it is giving specific version for RTLs but in VC10 it is copying at System32 folder without specific to any version.

    I'm not sure in future MS will follow same pattern as in VC8 but right now it is copying at System32 folder so it appears that we can check by registry entry.

    Aaron, any help is appreciable.

  11. madhur_tiwari@hotmail.com says:

    Hi Aaron, I've verified it is making entry in registry at \Software\Microsoft\VisualStudio\10.0\VC\VCRedist\x86 at PC that does not have VS 2010, so it can be used but as per your suggession I can read particular .msi file from

    HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionUninstall{productcode}, I'll try this one and check whether up to what extent it can give information e.g. version, which service pack etc.. Thanks Aaron for your all around help

  12. astebner says:

    Hi Madhur – I'm sorry I provided incorrect information earlier about the version of Windows Installer that is required by the VC++ redistributable.  I looked at the schema in the MSI in Orca, and it says 200, but I didn't look at what the setup bootstrapper is checking for.  You will need to make sure that Windows Installer 3.1 or higher is installed on any computers that you install the VC++ 2010 Redistributable on.

    The VC++ 2010 runtime files install to the system directory (instead of to the WinSxS directory used by previous versions of the VC++ runtime files).  As a result, if you're going to perform a file version check, you'll need to check in the system directory.  The registry-based check for the redistributable MSI should also work in this type of scenario if you'd prefer.

  13. madhur_tiwari@hotmail.com says:

    Hi Aaron, No probs for installer and no need to feel sorry..How can we verify whether Visual C++ 2010 Redistributable supports Side by Side installation (i.e. multiple versions exist)

  14. astebner says:

    Hi Madhur – I'm not sure about this side-by-side question yet.  For now, you can try to examine the VC++ 2010 SP1 beta redistributable that is available at http://www.microsoft.com/…/details.aspx and see if it supports side-by-side installation with the original version of the VC++ 2010 redistributable.

    Keep in mind that this is a beta though, so the behavior you see may not be the same in the final SP1 release.

  15. madhur_tiwari@hotmail.com says:

    Thanks Aaron for quick response..I mean for side by side installation in VCRT8 it was creating separate folders for each version and keeping dll inside that, but in VCRT10 if it is copying System 32 folder but I've just tried with VCRT10 SP1 Beta installation and it has overridden earlier installation so it is not keeping both versions.

    As my application is to move VC8 to VC10 and dotnet 2.0 to 4.0 so need to maintain side by side functionality by installing multiple versions.

    The registry-based check for the redistributable MSI should also work in this type of scenario – Can you please litte explore or give me link where I can see some sample code for this?

  16. astebner says:

    Hi Madhur – Because the VC++ 2010 runtime files install to system32, the various service packs cannot install to side-by-side locations like the older versions did when they installed to sub-folders under WinSxS.  If your application requires the VC++ 2010 files but the exact build number doesn't matter, you can detect the install state by using the registry key at HKEY_LOCAL_MACHINESoftwareMicrosoftVisualStudio10.0VCVCRedistx86.  If your applicatoin requires an exact build number of the VC++ 2010 files, you will likely need to do file version checks on the files in system32.

  17. Madhur says:

    Thanks Aaron!! When I'm trying to use MsiQueryProductState("{196BB40D-1578-3D01-B289-BEFC77A11A1E}") getting linking error LNK2001: unresolved external symbol _MsiQueryProductStateA@4 and

    fatal error LNK1120: 1 unresolved externals

    ——————————————————————

    #include <windows.h>

    #include <stdio.h>

    #include <msi.h>

    void main()

    {

    int status = MsiQueryProductState("{196BB40D-1578-3D01-B289-BEFC77A11A1E}");

    }

    Not sure why this linking error is appearing.

  18. astebner says:

    Hi Madhur – I think you'll need to add msi.lib to the list of libraries you link against in your project to resolve this error.

  19. madhur_tiwari@hotmail.com says:

    Thanks Aaron for your quick help!! It resolved by adding msi.lib

    I believe this product id will be separate for each version/patch of VC10 Redistributables. So that I can check specific version of RTL. Please correct me if I'm assuming incorrectly.

  20. astebner says:

    Hi Madhur – You'll need to be careful about using the product code for detection.  It looks to me like the SP1 MSI will do a major upgrade of the RTM MSI.  That means that if you install SP1 on a computer that has RTM, it will automatically uninstall the RTM MSI behind the scenes during SP1 setup.  If your application setup is checking for the RTM product code, but the machine already has SP1, it will return the incorrect result.  Also, if your application setup tries to install the RTM MSI in this scenario, the RTM MSI will fail because a newer version is already installed.

  21. madhur_tiwari@hotmail.com says:

    Hi Aaron, For Visual C++ 2010 SP1 Beta Redistributable Package (x86), I'm getting Family Id i.e. 6201A933-4806-4036-8895-A340D7BEBF10, but not able to locate Product Id. I tried from microsoft site but could not get. I believe Product Id and Family Id are different. Is there any way to get product id for VCRT10 SP1 Beta?

  22. madhur_tiwari@hotmail.com says:

    Yes Aaron!! I agree with you. when I installed VCRT10 SP1 Beta then behind the scene it has uninstalled main version of VCRT10. When I tried to install VCRT10 again then it gave message that it already has higher version installed.

    This means VCRT10 is not going to support Side by Side installation because newer version is replacing older one.

  23. astebner says:

    Hi Madhur – The family ID is only used by the Microsoft Download Center when it hosts files.  You can find the product code by opening the MSI in Orca (msdn.microsoft.com/…/aa370557.aspx).  For the VC++ 2010 SP1 beta, the product code is {58D8485F-FEB8-32AB-9A3D-6AD6C6E78F40}.

    Correct, the VC++ 2010 Redistributable SP1 MSI doesn't support side-by-side install with the RTM MSI, but the payload installed by the SP1 MSI should be backwards compatible so that if you have SP1 installed, you can run applications built with RTM or SP1.

  24. madhur_tiwari@hotmail.com says:

    Thanks Aaron!! So There are two ways to check particular version is installed or not. First, check through Product Id using MsiQueryProductState API and second is using File version of any redistributable file e.g. ATL100.dll.

    Using product code may have access right issue.

    I'm not sure which way is better in less maintenance wise. Please guide.

  25. astebner says:

    Hi Madhur – I'd suggest using a registry check or a file version check.  The product code check will not end up being reliable because newer service packs perform major upgrades of older service packs.

  26. madhur_tiwari@hotmail.com says:

    Thanks Aaron!! So If I'll use registry check then I need to again use product code from HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionUninstall{productcode},

    but as per your suggestion product code is not reliable and if I use file version check then I need to hard code so much code for comparing then i need to change again and again.

  27. astebner says:

    Hi Madhur – For the registry check, I was thinking you should use a key that exists in the RTM version and in the SP1 version, like this:

    [HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0VCVCRedistx86]

    Installed = 1 (REG_DWORD)

    You shouldn't use a registry key that depends on the product code because you'll run into the same potential set of issues that you'd run into if you tried to check the install state of the product code directly with MsiQueryProductState.

    If you use a file version check, you shouldn't need to hard-code much.  You should verify that the file exists and check for a major version that is at least 10 and that should be all you need.

  28. madhur_tiwari@hotmail.com says:

    Thanks Aaron!!

    I struk in an another issue. When I'm compiling VS2005 C++ project in VS2010 then encountering MIDL 2400/2401 warnings.

    I tried to search but could not get sure shot answer.

    Solution: If we remove optional attribute then warnings may go off but not sure how much it is reliable. I mean it should not break functionality.

  29. astebner says:

    Hi Madhur – I'm not sure I understand the issue that you're describing.  Are you trying to upgrade a Visual C++ 2005 project and then build it in Visual C++ 2010?  If so, then solving this type of warnings is not really in my areas of expertise, and I'd suggest posting a question on one of the Visual C++ forums at social.msdn.microsoft.com/…/visualc.

  30. Ole says:

    Which version of the redistributable (i.e. x86 or x64) is required to run 32-bit applications on a 64-bit OS?

    Does this depend on the OS (the .NET way) or on the applications to be executed (the VS2008 way)?

  31. astebner says:

    Hi Ole – You will need the x86 redistributable in order to be able to run 32-bit applications, regardless of what OS you run them on.

  32. Michel says:

    Hi Aaron,

    Thanks for the great info.

    What's the difference in running the exe in silent mode in 'repair' mode (<full path>vcredist_x86.exe /q /repair /norestart

    ) or running it in simply 'install' mode even in case when it is already installed? Would it make any difference? Is the exe intelligent enough to fall back to 'repair' automatically in case it finds VCredist already installed, but the repair option is not specifically specified?

  33. astebner says:

    Hi Michel – You can run the install command line and it should do a new install if the VC++ redistributable is not yet installed or a repair if it is already installed.  Please let me know if you run into any issues when trying to do this.

  34. Michel says:

    Yes, it seemss to work, but it looks to me that vcredist repair is broken from MS side itself. What I did was to install VCredist 2010 x86 (in UI mode), deleted file 'msvcr100' from c:windoessystem32', then again run vcredist 2010 x86 (in UI mode) and choose repair. To my surprise, the file was not reverted back. Strange, but seems that vcredist repair is not working on expected line. It is not putting back the corrupt/missing files!

  35. astebner says:

    Hi Michel – The verbose MSI log file should show why that file is not being restored.  Do you have a copy of a verbose MSI log file from this scenario that you could upload to a file server (such as http://skydrive.live.com) and provide a link here so I could take a look?

  36. John Doe says:

    Hi Aaron,

    Can you elaborate under what circumstances reboot after install may be required?

    Thanks.

  37. astebner says:

    Hi John Doe – Reboot prompts occur when a setup needs to update resources (normally files, but also possibly things like registry keys/values, services, etc) that are being held in use by other processes on the computer.

  38. Mandeep says:

    We are installing VC redist 2012 (version 10.0.40219.01) along with our application.

    We used the Installshield and the VC 2010 prerequisite, since it was older version 10.0.30319 we updated it with newer vcredist.exe.

    on x32 bit machines, without this redistributable our install prompts to install VC 2010 redist.

    But, on x64 bit machines, we are not getting the prompt from our installer to install VC redist 2010.

    My question is,

    How are companies deploying VC 2010 redist, –

    a) Use the prq which has set of conditions as it checks to see if vcredist needs to be installed.

    or

    b) just set a custom action to run the VCredist and run it in silent mode so user do not get the install.

    Please, any help is needed. It is urgent.

    thanks,

    Mandeep

  39. astebner says:

    Hi Mandeep – I don't know for sure how companies are doing this, but I can answer with my recommendation.  I'd suggest that you always run the VC redistributable installer in silent mode and don't try to detect if it is already installed.  I don't suggest running this as an MSI custom action though – you should use a chainer and have the chainer run the VC redistributable installer.

  40. Shashi says:

    Thanks Aaron for the helpful information.

    I am getting the UAC prompt while VCRedist 2010 both (x86 & x64) silently install.

    I tried following commands –

    1. <full path>vcredist_x86.exe /q /norestart

    2. <full path>vcredist_x64.exe /passive /norestart

    Please let me know the command which does not prompt for UAC.

    Thanks you.

    Shashi

  41. astebner says:

    Hi Shashi – These installers require elevated privileges in order to install correctly, and there isn't a way to suppress that requirement.  If you want the installation process to not show a UAC prompt, it is the responsibility of the calling process to make sure that the installer is launched with elevated privileges in the first place.

  42. Nikki says:

    Hi, Aaron:

    I have the same issue as well.  Even though the logged in user belongs to administrator group, it still prompt "Do you want to allow the following program to make changes to this computer?" while installing VC redistributable.  I thought admin group is supposed to have all required privilege??  

    Also, there is a way to set windows/MSI property (IMSIDEPLOYMENTCOMPLIANT) to avoid UAC prompt in MSI projects.  It will also make registry update fine.  Is there any equavalent setting when launching redistributables in silent mode?

    Your help will be really appreciated.  Thanks!

    Nikki

  43. astebner says:

    Hi Nikki – Even if a user is in the Administrators group, they will need to respond to an elevation prompt before being allowed to install a per-machine .msi like the VC redistributable (unless UAC is disabled in the Windows control panel).  There isn't a property that you can set to bypass that behavior.  When launching redistributable setup packages in silent mode, it is up to the calling process to make sure that the child process is launched with elevated privileges.  Usually, that means that the parent setup will need to prompt for elevation prior to running any child setup processes.

  44. Peter says:

    I am getting some strage effects. I am starting VcRedist_x86.exe from an application that has prompted for UAC privileges, and must have obtained them to get to the point where VcRedist_x86.exe is started. I am using MsiQueryProductState and checking for (not)INSTALLSTATE_DEFAULT before continuing by calling VcRedist_x86.exe /passive /norestart.

    A number of people have reported getting a VcRedist repair window (and failed install). I do not get the same problem on my own PCs (Win7 and Win8.1). What on earth could possibly be going on here?

    Any ideas would be very much appreciated.

  45. astebner says:

    Hi Peter – If the MSI API says that the product is not installed and the repair fails, then it is possible that the installed version is not actually the same as the one your application is trying to install.  Does your application create any log files that you can have the customers send when they hit this behavior?  Also, can you have your customers run the steps listed at blogs.msdn.com/…/434814.aspx to collect a list of installed programs on their computer so you can compare the installed VC redist versions to the one your application is trying to install?

  46. Dave says:

    If you do the silent install, do you have to include Microsoft's redistributable license agreement in your own so that the users must approve that?

  47. astebner says:

    Hi Dave – I'm sorry, but I don't know the legal requirements here.  I'd suggest posting a question on the Visual Studio setup forum at social.msdn.microsoft.com/…/home to see if someone there knows the answer to this question.

    1. yaro says:

      I’m installing on a remote machine where the .exe is located on the target. I run /passive /norestart but the installation never happens. I tried adding the /log switch to generate some report but nothing gets generated. UAC disabled.

      1. Hi yaro – How are you invoking the .exe on the target? Do you see any entries in the Application event log on the target that might explain why it is failing to launch the installer?

        1. yaro says:

          I go the Invoke-command way triggering Start-process with -ArgumentList

          1. yaro says:

            Turns up it all works fine just given the path and args so without start-process in the script block.