Inno Setup packaged exe program plus [unins.exe] uninstaller

I made an exe program before, and after packaging it with inno, I found it inconvenient to uninstall. See that other programs have unins.exe uninstaller and the like. So I searched on the Internet, modified the format problem, and the test was successful. record here

  • It is mainly innoto add a few statements in the script (the comments have been marked, please read carefully)
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "boc-plug"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"
#define MyAppExeName "boc-plug.exe"
#define MyAppAssocName MyAppName + ""
#define MyAppAssocExt ".exe"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={
    
    {
    
    D9A40C54-DC21-428E-A915-D7543C860765}
AppName={
    
    #MyAppName}
AppVersion={
    
    #MyAppVersion}
;AppVerName={
    
    #MyAppName} {
    
    #MyAppVersion}
AppPublisher={
    
    #MyAppPublisher}
AppPublisherURL={
    
    #MyAppURL}
AppSupportURL={
    
    #MyAppURL}
AppUpdatesURL={
    
    #MyAppURL}
DefaultDirName={
    
    autopf}\{
    
    #MyAppName}
ChangesAssociations=yes
DisableProgramGroupPage=yes
LicenseFile=D:\workdoc\中国银行金库\jinku\code\buildexe\0926\exe\1.txt
InfoBeforeFile=D:\workdoc\中国银行金库\jinku\code\buildexe\0926\exe\2.txt
InfoAfterFile=D:\workdoc\中国银行金库\jinku\code\buildexe\0926\exe\3.txt
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=D:\workdoc\中国银行金库\jinku\code\buildexe\0926\out
OutputBaseFilename=boc-setup
Compression=lzma
SolidCompression=yes
WizardStyle=modern

// 下面两句,如果你的脚本里没有,添加上,直接复制
Uninstallable=yes
UninstallDisplayName=卸载{
    
    #MyAppName}

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "D:\workdoc\中国银行金库\jinku\code\buildexe\0926\exep2\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\workdoc\中国银行金库\jinku\code\buildexe\0926\exep2\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

// 下面[code]到[Registry]之间的内容直接复制到你的脚本里
[code]
  function InitializeSetup: Boolean;
  var Isbl: boolean;         //声明变量
    var Isstr: string;
    //全局变量
    var MyProgChecked: Boolean;
  var Path:string ;
         ResultCode: Integer;
  begin
    if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\.NETFramework\policy\v2.0') then
      begin
         Result := true;
     end
    else
      begin
        if MsgBox('系统检测到您没有安装.Net Framework2.0,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
          begin
               Path := ExpandConstant('{
    
    pf}\Internet Explorer\iexplore.exe');
               Exec(Path, 'http://data.zhiluo.net/soft/Microsoft_DotNet2.0.rar', '' , SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
               MsgBox('请安装好.Net Framework2.0环境后,再运行本安装包程序!',mbInformation,MB_OK);
               Result := false;
           end
        else
           begin
               MsgBox('没有安装.Net Framework2.0环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);
               Result := false;
           end;
      end;

      begin       //开始
        Isbl := true;             //变量赋值  注意下方的“SOFTWARE\IT_soft”要与安装时创建的注册表信息一致
        Isstr := '欢迎';
        if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\IT_soft', 'config') then
          begin
            MsgBox('软件已安装过,如果需要重新安装,请先卸载再安装!',mbConfirmation, MB_OK);
            isbl := false;
          end
        else
          begin
          //MsgBox(‘无值‘,mbConfirmation, MB_OK);
          isbl := true;
          end;
          Result := Isbl;
      end;       //结束
  end;

[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{
    
    app}\{
    
    #MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
// 下面这句需要添加
Name: "{group}\卸载 {#MyAppName}"; Filename: "{uninstallexe}"

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent


Guess you like

Origin blog.csdn.net/qq_31424825/article/details/127071742