您好我正在尝试在我的 Inno Setup 脚本中集成 .NET Framework 版本检查和自动安装。
我正在使用我在这里找到的代码:.../installing-net-framework-4-5-automatically-with-inno-setup/ `
问题是,代码不起作用。该脚本编译并输出正常。
当我尝试在 VM 中运行设置时,一切正常。
但是,我没有看到实际安装的 .NET Framework。
只是一个 10 秒的快速进度窗口,显示正在提取的各种文件(如下所示)。
然后它消失了,我的设置完成了。
当我尝试启动我的程序时,它报告未安装 .NET Framework。
这是完整的代码:
#include <idp.iss>
function Framework45IsNotInstalled(): Boolean;
var
bSuccess: Boolean;
regVersion: Cardinal;
begin
Result := True;
bSuccess := RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', regVersion);
if (True = bSuccess) and (regVersion >= 378389) then begin
Result := False;
end;
end;
procedure InitializeWizard;
begin
if Framework45IsNotInstalled() then
begin
idpAddFile('http://go.microsoft.com/fwlink/?LinkId=397707', ExpandConstant('{tmp}\NetFrameworkInstaller.exe'));
idpDownloadAfter(wpReady);
end;
end;
procedure InstallFramework;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing .NET Framework 4.5.2. This might take a few minutes…';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\NetFrameworkInstaller.exe'), '/passive /norestart','', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.', mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
DeleteFile(ExpandConstant('{tmp}\NetFrameworkInstaller.exe'));
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssPostInstall:
begin
if Framework45IsNotInstalled() then
begin
InstallFramework();
end;
end;
end;
end;
我尝试分解代码并试图找出问题所在。不幸的是,我无法识别它。
任何帮助将不胜感激。谢谢!