inno setup compiler 6.2.0

; -- Example1.iss --
; Demonstrates copying 3 files and creating an icon.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=RouteEMT
AppVersion=v1.0.0
WizardStyle=modern
DefaultDirName={autopf}\RouteEMTV1.0.0
DefaultGroupName=RouteEMTV1.0.0
UninstallDisplayIcon={app}\uninstall_RouteEMTV1.0.0.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output
ShowLanguageDialog = yes
[Languages]
Name: "chinese"; MessagesFile: "compiler:Languages\Chinese.isl"

[Files]
Source: "RouteEmt.exe"; DestDir: "{app}"
Source: "路由器返修配置.xml"; DestDir: "{app}"
Source: "WinPcap_4_1_1.exe"; DestDir: "{app}"
[Run]
Filename: "{app}\WinPcap_4_1_1.exe"; Check: ShouldInstall
[Code]


function ShouldInstall: Boolean;
var
  Version: String;
  install: cardinal;
begin
  // 检查软件版本是否已安装
  if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Install', install) then
  begin
      // 已经安装了最新版本,不需要再次安装
      MsgBox(Format('install is %d.', [install]), mbInformation, MB_OK);
      Result := (install =1);
      Exit;
  end;

  Result := True;
end;

procedure AfterMyProgInstall(S: String);
var
  FileName: String;
  ResultCode: Integer;
begin
  Log('AfterMyProgInstall(''' + S + ''') called');
  //MsgBox('AfterMyProgInstall:' #13#13 'Setup just installed ' + S + ' as ' + CurrentFileName + '.', mbInformation, MB_OK);
  //MsgBox('安装程序将要安装: ' + S  + ',如果已经安装,程序会给出提示', mbInformation, MB_OK);
  FileName := ExpandConstant('{app}')+'\'+S;
  if not Exec(FileName, '', '', SW_SHOWNORMAL, ewNoWait, ResultCode) 
  then  
    MsgBox('依赖安装失败:' +S,mbInformation,MB_OK);
end;


 function IsDotNetDetected(version: string; service: cardinal): boolean;
 
 var
     key, versionKey: string;
     install, release, serviceCount, versionRelease: cardinal;
     success: boolean;
 begin
     versionKey := version;
     versionRelease := 0;
 
     // .NET 1.1 and 2.0 embed release number in version key
     if version = 'v1.1' then begin
         versionKey := 'v1.1.4322';
     end else if version = 'v2.0' then begin
         versionKey := 'v2.0.50727';
     end
 
     // .NET 4.5 and newer install as update to .NET 4.0 Full
     else if Pos('v4.', version) = 1 then begin
         versionKey := 'v4\Full';
         case version of
           'v4.5':   versionRelease := 378389;
           'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older
           'v4.5.2': versionRelease := 379893;
           'v4.6':   versionRelease := 393295; // 393297 on Windows 8.1 and older
           'v4.6.1': versionRelease := 394254; // 394271 on Windows 8.1 and older
           'v4.6.2': versionRelease := 394802; // 394806 on Windows 8.1 and older
         end;
     end;
 
     // installation key group for all .NET versions
     key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey;
 
     // .NET 3.0 uses value InstallSuccess in subkey Setup
     if Pos('v3.0', version) = 1 then begin
         success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
     end else begin
         success := RegQueryDWordValue(HKLM, key, 'Install', install);
     end;
 
     // .NET 4.0 and newer use value Servicing instead of SP
     if Pos('v4', version) = 1 then begin
         success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
     end else begin
         success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
     end;
 
     // .NET 4.5 and newer use additional value Release
     if versionRelease > 0 then begin
         success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
         success := success and (release >= versionRelease);
     end;
 
     result := success and (install = 1) and (serviceCount >= service);
 end;
 
 
 function InitializeSetup(): Boolean;
 var Path:string;
 ResultCode: Integer;
 begin
     if not IsDotNetDetected('v4.5', 0) then begin
         ExtractTemporaryFile('NDP452-KB2901907-x86-x64-AllOS-ENU.exe');
         Exec(ExpandConstant('{tmp}\NDP452-KB2901907-x86-x64-AllOS-ENU.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
         result := true;
     end else
         result := true;
 end;

[Icons]
Name: "{group}\RouteEMTV1.0.0"; Filename: "{app}\RouteEmt.exe"

 

2、 .net 版本相关

https://blog.csdn.net/Learn_change_myself/article/details/123183005

 

3、参考这个,安装ok

https://zhuanlan.zhihu.com/p/51658788

 https://blog.csdn.net/weixin_44734310/article/details/116838746

 

 

----

晚上要在家试下

; -- Example1.iss --
; Demonstrates copying 3 files and creating an icon.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=RouteEMT
AppVersion=v1.0.0
WizardStyle=modern
DefaultDirName={autopf}\RouteEMTV1.0.0
DefaultGroupName=RouteEMTV1.0.0
UninstallDisplayIcon={app}\uninstall_RouteEMTV1.0.0.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output
ShowLanguageDialog = yes
[Languages]
Name: "chinese"; MessagesFile: "compiler:Languages\Chinese.isl"

[Files]
Source: "RouteEmt.exe"; DestDir: "{app}"
Source: "路由器返修配置.xml"; DestDir: "{app}"
Source: "emt安装说明.pdf"; DestDir: "{app}";Flags: isreadme
Source: "WinPcap_4_1_1.exe"; DestDir: "{app}";  AfterInstall: AfterMyProgInstall('WinPcap_4_1_1.exe')
[Run]

[Code]
//Filename: "{app}\WinPcap_4_1_1.exe"; Check: ShouldInstall
procedure ExitProcess(exitCode:integer);
  external 'ExitProcess@kernel32.dll stdcall';

function checkDotNet: Boolean;
var
  Version: String;
  install: cardinal;
  ErrorCode: Integer;
begin
  // 检查软件版本是否已安装
  if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Install', install) then
  begin
      //已经安装了最新版本,不需要再次安装
      //MsgBox(Format('install is %d.', [install]), mbInformation, MB_OK);
      Result := (install =1);
      if(Result <> True) then
      begin
          MsgBox('安装程序发现本电脑没有安装.net4.8 , 请先根据跳转链接下载安装程序并安装,然后再执行本安装程序。 安装程序将退出!', mbInformation, MB_OK);
        ShellExec('open','https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe','','',SW_SHOWNORMAL, ewNoWait, ErrorCode);
        ExitProcess(9);
      end;
      Exit;
  end;
  //if(in)  Servicing      Full Install
  //MsgBox(Format('thainstall is %d.', [install]), mbInformation, MB_OK);
  //ShellExec('open','https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe','','',SW_SHOWNORMAL, ewNoWait, ErrorCode);
  Result := True;
end;

procedure AfterMyProgInstall(S: String);
var
  FileName: String;
  ResultCode: Integer;
begin
  Log('AfterMyProgInstall(''' + S + ''') called');
  //MsgBox('AfterMyProgInstall:' #13#13 'Setup just installed ' + S + ' as ' + CurrentFileName + '.', mbInformation, MB_OK);
  //MsgBox('安装程序将要安装: ' + S  + ',如果已经安装,程序会给出提示', mbInformation, MB_OK);
  FileName := ExpandConstant('{app}')+'\'+S;
  if not Exec(FileName, '', '', SW_SHOWNORMAL, ewNoWait, ResultCode) 
  then  
    MsgBox('依赖安装失败:' +S,mbInformation,MB_OK);
end;

function PrepareToInstall(var NeedsRestart: Boolean): String;
var
  ChecksumBefore, ChecksumAfter: String;
begin
  checkDotNet();
end;
 

[Icons]
Name: "{group}\RouteEMTV1.0.0"; Filename: "{app}\RouteEmt.exe"

 

posted @ 2023-10-25 19:30  cnchengv  阅读(9)  评论(0编辑  收藏  举报