How do I install .NET Framework only when it's not already installed?

后端 未结 1 551
北荒
北荒 2020-11-29 05:14

Is there a way to check if the .NET Framework 4 has been installed and install it only when it\'s not in the system?

I know, how do I determine, if the .NET Framewor

相关标签:
1条回答
  • 2020-11-29 05:31

    The easiest you can do, is to use the Check parameter, which allows you to control if a certain file from the [Files] section will be extracted, or if a certain program from the [Run] section will be executed. The following script code shows its usage for the conditional installation of the .NET Framework 4:

    [Files]
    Source: "dotNetFx40_Full_setup.exe"; DestDir: {tmp}; \
      Flags: deleteafterinstall; Check: FrameworkIsNotInstalled
    
    [Run]
    Filename: "{tmp}\dotNetFx40_Full_setup.exe"; Check: FrameworkIsNotInstalled
    
    [Code]
    
    function FrameworkIsNotInstalled: Boolean;
    begin
      Result :=
        not RegKeyExists(
          HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.0');
    end;
    
    0 讨论(0)
提交回复
热议问题