2014-12-20 7 views
5

Sto usando Inno Setup trova qui http://www.jrsoftware.org/Inno Setup per Visual C++ Redistributable Package per Visual Studio 2013

Sono anche utilizzando modulare InnoSetup Dipendenza Installer si trova qui http://www.codeproject.com/Articles/20868/NET-Framework-Installer-for-InnoSetup

Ho un progetto che ha bisogno di Visual C++ Pacchetto ridistribuibile per Visual Studio 2013 disponibile qui. http://www.microsoft.com/en-us/download/details.aspx?id=40784

Sto cercando di modificare un file prodotto dal programma di installazione modulare Inno Seup Dipendenza. Ho copiato e modificato il file da vcredist2010.iss in vcredist2013.iss, ma il problema è che ogni volta che lo installa scarica nuovamente il tempo di esecuzione di C++ 2013. Non penso che stia rilevando l'installazione, quindi sta reinstallando ogni volta.

Ecco il codice ho attualmente ..

// requires Windows 7 Service Pack 1, Windows 8, Windows 8.1, Windows Server 2003, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 2012, Windows Server 2012 R2, Windows Vista Service Pack 2, Windows XP Service Pack 3 
// requires Windows Installer 3.1 or later (??) 
// requires Internet Explorer 5.01 or later (??) 
// http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992 

[CustomMessages] 
vcredist2013_title=Visual C++ 2013 Redistributable 

en.vcredist2013_size=6.2 MB 
de.vcredist2013_size=6,2 MB 

en.vcredist2013_size_x64=6.9 MB 
de.vcredist2013_size_x64=6,9 MB 

;http://www.microsoft.com/globaldev/reference/lcid-all.mspx 
en.vcredist2013_lcid='' 
de.vcredist2013_lcid='/lcid 1031 ' 

[Code] 
const 
    vcredist2013_url = 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe'; 
    vcredist2013_url_x64 = 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'; 


procedure vcredist2013(); 
var 
    version: cardinal; 
begin 
    RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\12.0\VC\VCRedist\' + GetString('x86', 'x64',''), 'Installed', version); 

    if (version <> 1) then 
    AddProduct('vcredist2013' + GetArchitectureString() + '.exe', 
      CustomMessage('vcredist2013_lcid') + '/passive /norestart', 
      CustomMessage('vcredist2013_title'), 
     CustomMessage('vcredist2013_size' + GetArchitectureString()), 
      GetString(vcredist2013_url, vcredist2013_url_x64,''),false, false); 
end; 

Qualcuno ha un modo migliore di fare questo?

Grazie.

Aggiornamento

Ecco l'ultima versione.

// requires Windows 7 Service Pack 1, Windows 8, Windows 8.1, Windows Server 2003, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 2012, Windows Server 2012 R2, Windows Vista Service Pack 2, Windows XP Service Pack 3 
// requires Windows Installer 3.1 or later (??) 
// requires Internet Explorer 5.01 or later (??) 
// http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992 
// Thank you (Martyn) https://allthingsconfigmgr.wordpress.com/2013/12/17/visual-c-redistributables-made-simple/ 
// http://stackoverflow.com/questions/27582762/inno-setup-for-visual-c-redistributable-package-for-visual-studio-2013 
// http://stackoverflow.com/questions/11137424/how-to-make-vcredist-x86-reinstall-only-if-not-yet-installed 

[CustomMessages] 
vcredist2013_title=Visual C++ 2013 Redistribute (32bit) 
vcredist2013_title_x64=Visual C++ 2013 Redistribute (64bit) 

en.vcredist2013_size=6.2 MB 
de.vcredist2013_size=6,2 MB 

en.vcredist2013_size_x64=6.9 MB 
de.vcredist2013_size_x64=6,9 MB 

;http://www.microsoft.com/globaldev/reference/lcid-all.mspx 
en.vcredist2013_lcid='' 
de.vcredist2013_lcid='/lcid 1031 ' 

[Code] 
#IFDEF UNICODE 
    #DEFINE AW "W" 
#ELSE 
    #DEFINE AW "A" 
#ENDIF 
type 
    INSTALLSTATE = Longint; 
const 
    INSTALLSTATE_INVALIDARG = -2; // An invalid parameter was passed to the function. 
    INSTALLSTATE_UNKNOWN = -1;  // The product is neither advertised or installed. 
    INSTALLSTATE_ADVERTISED = 1; // The product is advertised but not installed. 
    INSTALLSTATE_ABSENT = 2;  // The product is installed for a different user. 
    INSTALLSTATE_DEFAULT = 5;  // The product is installed for the current user. 

    //DOWNLOADS FOR VISUAL C++ 2013 
    VC_REDIST2013_URL = 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe'; 
    VC_REDIST2013_URL_x64 = 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'; 

    //OPTIONS 
    VC_2013_REDIST = '{13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}'; //Microsoft.VS.VC_RuntimeMinimumVSU_x86,v12 
    VC_2013_REDIST_x64 = '{A749D8E6-B613-3BE3-8F5F-045C84EBA29B}'; //Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v12 

    function MsiQueryProductState(szProduct: String): INSTALLSTATE; 
    external 'MsiQueryProductState{#AW}@msi.dll stdcall'; 

function VCVersionInstalled(const ProductID: String): Boolean; 
begin 
    Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT; 
end; 

procedure vcredist2013(); 
var 
    target_x86_Only: Boolean; 
    target_x64_Only: Boolean; 
    target_x64x86_Either: Boolean; 
begin 
    //OPTION SETTINGS ONE TRUE ONLY 
    target_x86_Only := True; 
    target_x64_Only := False; 
    target_x64x86_Either := False; 
    //END OPTION SETTINGS 


    //Will Install 32 bit only. 
    if (target_x86_only = True) then begin 
     if NOT VCVersionInstalled(VC_2013_REDIST) then 
      AddProduct('vcredist_x86.exe', 
       CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
       CustomMessage('vcredist2013_title'), 
       CustomMessage('vcredist2013_size'), 
       VC_REDIST2013_URL, 
       false, false); 
    end;  

    //Will attempt to install 64 bit only 
    if (target_x64_Only) then begin 
     if (IsX64) then begin 
      if NOT VCVersionInstalled(VC_2013_REDIST_x64) then 
       AddProduct('vcredist_x64.exe', 
        CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
        CustomMessage('vcredist2013_title_x64'), 
        CustomMessage('vcredist2013_size_x64'), 
        VC_REDIST2013_URL_x64, 
        false, false); 
      end else begin 
      MsgBox('Sorry Cant install x64 application on x86 machine.', mbInformation, MB_OK); 
      end; 
    end; 

    //Will attempt to install x64 and if it's not available it will install the x86 version 
    if (target_x64x86_Either) then begin 
     if (IsX64) then begin 
      if NOT VCVersionInstalled(VC_2013_REDIST_x64) then 
       AddProduct('vcredist_x64.exe', 
        CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
        CustomMessage('vcredist2013_title_x64'), 
        CustomMessage('vcredist2013_size_x64'), 
        VC_REDIST2013_URL_x64, 
        false, false); 
      end else begin 
       if NOT VCVersionInstalled(VC_2013_REDIST) then 
       AddProduct('vcredist_x86.exe', 
       CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
       CustomMessage('vcredist2013_title'), 
       CustomMessage('vcredist2013_size'), 
       VC_REDIST2013_URL, 
        false, false); 
      end; 
    end; 
end; 
+1

Sei sicuro di stare guardando la chiave di registro corretta? * VisualStudio \ 12.0 \ VC \ VCRedist \ *. È la chiave che indica che il 2013 è stato installato? In caso contrario, verrà reinstallato ogni volta perché stai controllando la versione dalla chiave sbagliata. –

+0

Aprendo regedit non sembra che stia trovando quella chiave .... Ho cercato un modo per rilevarlo .. La parte strana è che la versione 2010 sembra funzionare correttamente .... da quello che posso dire .. O forse Vista e XP è possibile rilevare in questo modo, ma non Windows 7 e fino? –

+0

Forse la domanda avrebbe dovuto essere come rilevare se Visual C++ Redistributable è stato installato? http://www.eatoncode.com/shareit/2014-12-20_1216.png –

risposta

3

@TLama Grazie per tutto il vostro aiuto su questo ...

Ecco la mia versione finale .....

// requires Windows 7 Service Pack 1, Windows 8, Windows 8.1, Windows Server 2003, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 2012, Windows Server 2012 R2, Windows Vista Service Pack 2, Windows XP Service Pack 3 
// requires Windows Installer 3.1 or later (??) 
// requires Internet Explorer 5.01 or later (??) 
// http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992 
// Thank you (Martyn) https://allthingsconfigmgr.wordpress.com/2013/12/17/visual-c-redistributables-made-simple/ 
// http://stackoverflow.com/questions/27582762/inno-setup-for-visual-c-redistributable-package-for-visual-studio-2013 
// http://stackoverflow.com/questions/11137424/how-to-make-vcredist-x86-reinstall-only-if-not-yet-installed 

[CustomMessages] 
vcredist2013_title=Visual C++ 2013 Redistribute (32bit) 
vcredist2013_title_x64=Visual C++ 2013 Redistribute (64bit) 

en.vcredist2013_size=6.2 MB 
de.vcredist2013_size=6,2 MB 

en.vcredist2013_size_x64=6.9 MB 
de.vcredist2013_size_x64=6,9 MB 

;http://www.microsoft.com/globaldev/reference/lcid-all.mspx 
en.vcredist2013_lcid='' 
de.vcredist2013_lcid='/lcid 1031 ' 

[Code] 
#IFDEF UNICODE 
    #DEFINE AW "W" 
#ELSE 
    #DEFINE AW "A" 
#ENDIF 
type 
    INSTALLSTATE = Longint; 
const 
    INSTALLSTATE_INVALIDARG = -2; // An invalid parameter was passed to the function. 
    INSTALLSTATE_UNKNOWN = -1;  // The product is neither advertised or installed. 
    INSTALLSTATE_ADVERTISED = 1; // The product is advertised but not installed. 
    INSTALLSTATE_ABSENT = 2;  // The product is installed for a different user. 
    INSTALLSTATE_DEFAULT = 5;  // The product is installed for the current user. 

    //DOWNLOADS FOR VISUAL C++ 2013 
    VC_REDIST2013_URL = 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe'; 
    VC_REDIST2013_URL_x64 = 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'; 

    //OPTIONS 
    VC_2013_REDIST = '{13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}'; //Microsoft.VS.VC_RuntimeMinimumVSU_x86,v12 
    VC_2013_REDIST_x64 = '{A749D8E6-B613-3BE3-8F5F-045C84EBA29B}'; //Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v12 

    function MsiQueryProductState(szProduct: String): INSTALLSTATE; 
    external 'MsiQueryProductState{#AW}@msi.dll stdcall'; 

function VCVersionInstalled(const ProductID: String): Boolean; 
begin 
    Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT; 
end; 

procedure vcredist2013(); 
var 
    target_x86_Only: Boolean; 
    target_x64_Only: Boolean; 
    target_x64x86_Either: Boolean; 
begin 
    //OPTION SETTINGS ONE TRUE ONLY 
    target_x86_Only := True; 
    target_x64_Only := False; 
    target_x64x86_Either := False; 
    //END OPTION SETTINGS 


    //Will Install 32 bit only. 
    if (target_x86_only = True) then begin 
     if NOT VCVersionInstalled(VC_2013_REDIST) then 
      AddProduct('vcredist_x86.exe', 
       CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
       CustomMessage('vcredist2013_title'), 
       CustomMessage('vcredist2013_size'), 
       VC_REDIST2013_URL, 
       false, false); 
    end;  

    //Will attempt to install 64 bit only 
    if (target_x64_Only) then begin 
     if (IsX64) then begin 
      if NOT VCVersionInstalled(VC_2013_REDIST_x64) then 
       AddProduct('vcredist_x64.exe', 
        CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
        CustomMessage('vcredist2013_title_x64'), 
        CustomMessage('vcredist2013_size_x64'), 
        VC_REDIST2013_URL_x64, 
        false, false); 
      end else begin 
      MsgBox('Sorry Cant install x64 application on x86 machine.', mbInformation, MB_OK); 
      end; 
    end; 

    //Will attempt to install x64 and if it's not available it will install the x86 version 
    if (target_x64x86_Either) then begin 
     if (IsX64) then begin 
      if NOT VCVersionInstalled(VC_2013_REDIST_x64) then 
       AddProduct('vcredist_x64.exe', 
        CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
        CustomMessage('vcredist2013_title_x64'), 
        CustomMessage('vcredist2013_size_x64'), 
        VC_REDIST2013_URL_x64, 
        false, false); 
      end else begin 
       if NOT VCVersionInstalled(VC_2013_REDIST) then 
       AddProduct('vcredist_x86.exe', 
       CustomMessage('vcredist2013_lcid') + '/install /quiet /norestart', 
       CustomMessage('vcredist2013_title'), 
       CustomMessage('vcredist2013_size'), 
       VC_REDIST2013_URL, 
        false, false); 
      end; 
    end; 
end; 

spera che questo aiuta qualcun altro.

+4

L'autore di InnoSetup modulare Dependency Installer (stfx) ha aggiornato la sua collezione per includere questo codice in precedenza con un po 'più di correttezza - http://www.codeproject.com/Articles/20868/NET-Framework-Installer-for-InnoSetup Scarica qui la versione aggiornata. –

Problemi correlati