2013-07-26 74 views
0

我想在我的NSIS安裝腳本中安裝VC++ Redist 2008。我得到了下面的一段腳本來做到這一點:以靜默模式安裝VC++ Redist 2008

; 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 

基本上它VC++ 2005年的Redist,但我已經編輯了reg設定查看2008年的存在(是否確定要這麼做?)。我需要一段腳本/命令來安裝VC++ Redist 2008.

  • 我在哪裏存儲VC設置以及如何在靜默模式下執行。
  • 可以檢查.onInit嗎?

有人請給出一個完整的腳本,檢查是否存在以及如何在靜默模式下執行它。

感謝,

回答

0

好吧,我不是關於如何檢查是否vcredist已經從註冊表中安裝了太多肯定。 我爲我的安裝程序做的是檢查系統中的某個特定的dll文件,該文件安裝了vcredist(並且我正在爲其安裝vcredist)。因此,如果該文件存在於我的$ WinDir中,我假設vcredist已經安裝,否則我下載&安裝(靜默)vcredist

以下是我的腳本這可能是對你有所幫助:

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: