Aaron Stebner's WebLog

Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio

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

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

  • Comments 45

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

  • 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_MACHINE\Software\Microsoft\VisualStudio\10.0\VC\VCRedist\x86.  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.

  • 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.

  • 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.

  • 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.

  • 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.

  • 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?

  • 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.

  • 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.

  • 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.

  • 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.

  • Thanks Aaron!! So If I'll use registry check then I need to again use product code from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\{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.

  • 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_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86]

    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.

  • 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.

  • 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.

  • 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)?

Page 2 of 3 (45 items) 123
Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post