Thursday, September 2, 2010

Inno Setup MSVC vcredist without bothering your users

If your C++ program is compiled with MS Visual Studio 2005 Express, and you link with the DLL versions of the C run-time libraries, you probably already know that you have to run vcredist_x86.exe to install those dependencies on a new computer before your program will run.

Here's how to do that in an Inno Setup script.
First, download vcredist_x86.exe from MSDN, Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)
Notice that's for SP1, the instructions are different for non-SP1, and for the vcredist_x86.exe that comes with Visual Studio Standard or Professional. See the credit link below.

Include this in your script:

Source: {src}\bin\vcredist_x86.exe; DestDir: {app}\bin\;

Filename: {app}\bin\vcredist_x86.exe; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}\bin; StatusMsg: Installing CRT...

Alternative for x64 ( I haven't tested this):
Filename: {app}\bin\vcredist_x64.exe; Parameters: "/q:a /c:""VCREDI~2.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}\bin; StatusMsg: Installing CRT...

Note all those quotes. Also you can see that I include vcredist in a 'bin' subdirectory, and I install it along with the other files my app needs. That last param can be /qb! to show progress, or /qn for no interface at all.

I tracked this down from a helpful MSDN blog post. Go check it for the variants needed for other flavors of vcredist.....
Post a Comment