如何仅在尚未安装.NET Framework的情况下安装它? [英] How do I install .NET Framework only when it's not already installed?
问题描述
有没有一种方法可以检查是否已安装.NET Framework 4并仅在不在系统中时才安装它?
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?
我知道,我该怎么办?通过检查以下注册表项来确定是否安装了.NET Framework 4?
I know, how do I determine, if the .NET Framework 4 is installed by checking the following registry key?
hasDotnet4 :=
RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.0');
如何基于上述检查有条件地运行.NET Framework 4安装?
How do I conditionally run the .NET Framework 4 installation based on the above check?
推荐答案
最简单的方法是使用 Check
参数,它允许您控制是否来自 [文件]
部分,或者如果 [运行]
部分将被执行。以下脚本代码显示了其在.NET Framework 4的条件安装中的用法:
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;
这篇关于如何仅在尚未安装.NET Framework的情况下安装它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!