Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
582 views
in Technique[技术] by (71.8m points)

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

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 Framework 4 is installed by checking the following registry key?

hasDotnet4 :=
  RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWAREMicrosoft.NETFrameworkpolicyv4.0');

How do I conditionally run the .NET Framework 4 installation based on the above check?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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, 'SOFTWAREMicrosoft.NETFrameworkpolicyv4.0');
end;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...