Bomzinho
Bomzinho

Reputation: 161

Installing VC++ Redist 2008 in silent mode

I want to install VC++ Redist 2008 in my NSIS setup script. I got the following piece of script to do it:

; Test if Visual Studio Redistributables 2005+ SP1 installed
; Returns -1 if there is no VC redistributables intstalled
Function CheckVCRedist
   Push $R0
   ClearErrors
   ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7299052b-02a4-4627-81f2-1818da5d550d}" "Version"

   ; if VS 2005+ redist SP1 not installed, install it
   IfErrors 0 VSRedistInstalled
   StrCpy $R0 "-1"

VSRedistInstalled:
   Exch $R0
FunctionEnd

Basically its for VC++ Redist 2005, but i've edited the reg settings to check for presence of 2008(is it ok to do so?). I need the piece of script/command to install the VC++ Redist 2008.

Could someone please give a complete script which checks for presence and how to execute it in silent mode.

Thanks,

Upvotes: 0

Views: 2758

Answers (1)

foobar
foobar

Reputation: 2941

Well I am not much sure about how to check for if vcredist is already installed from registry. What I do for my installer is, to check for a particular dll file in the system which the vcredist installs (and for which I am installing vcredist). So if that file is present in my $WinDir I assume vcredist is already installed otherwise I download & install(silently) the vcredist.

Following is my script which may be of some help to you:

ifFileExists $Windir\System32\mfc100.dll +2 0
StrCpy $IsMfcInstalled "no"
${If} $IsMfcInstalled == "no"    
download1:
NSISdl::download "http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe"  "$Temp/vcredist_x86.exe"
pop $0
StrCmp "$0" "success" execStep1 instAbort1
execStep1:
Execwait '"$Temp/vcredist_x86.exe" /q' ; '/q' to install silently
pop $0
StrCmp "$0" "success" done execStep1
instAbort1:
StrCmp $0 "cancel" 0 +1
MessageBox MB_OKCANCEL "Connection Timed Out. Retry ? " IDOK  download1 IDCANCEL 0
Quit
${else}
goto done
${endIf}
done:

Upvotes: 1

Related Questions