用inno Setup做应用程序安装包的示例脚本(.iss文件)(

用innoSetup做应用程序安装包的示例脚本(.iss文件),具体要看innoSetup附带的文档,好象是pascal语言写的脚本。

示例1(应用程序.exe,客户端安装):

;{089D6802-6CD3-4E45-B8D5-AC9ED99CE371}; 脚本由 Inno Setup 脚本向导生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{5E012E21-42EE-4840-A000-35F9FAB886E9}
AppName=AIS_Client
AppVerName=AIS_Client
AppPublisher=公司名

DefaultDirName={pf}\AIS_Client
DefaultGroupName=AIS_Client
OutputBaseFilename=AIS_Client
Compression=lzma
SolidCompression=yes
SetupIconFile=D:\AIS\AIS 打包程序\AISGUI.ico
LicenseFile=C:\Documents and Settings\Administrator\桌面\许可协议.txt

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

[Files]
Source: "D:\AIS\AIS 打包程序\AIS_client_exe\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用"Flags: ignoreversion"

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

[Icons]
Name: "{group}\AIS客户端"; Filename: "{app}\AISGUI.exe"
Name: "{group}\AIS客户端参数配置工具"; Filename: "{app}\ClientConfig.exe"
Name: "{group}\AIS服务设置工具"; Filename: "{app}\ServiceIPManage.exe"
Name: "{group}\AIS数据库参数配置工具"; Filename: "{app}\DataBaseConfig.exe"
;Name: "{group}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"
;在开始菜单->所有程序->伴网书童里添加一个删除快捷键。
Name: "{group}\卸载"; Filename: {uninstallexe}
Name: "{commondesktop}\AIS客户端"; Filename: "{app}\AISGUI.exe"; Tasks: desktopicon
;Name: "{commondesktop}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"; Tasks: desktopicon

[Run]
;Filename: "{app}\Access_server\SecurityWare.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec
Filename: "{app}\AISGUI.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec

[Registry]
;添加开机启动
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName:"ais"; ValueData:"{app}\AISGUI.exe";  Flags:uninsdeletevalue

[Code]
{卸载时判断主程序是否在运行}
var
is_Sys , is_value: integer;
S_syschar, S_currentchar, S_current,S_sys, S,ResultStr : string;
I ,CloseNum: Integer;
ErrorCode: Integer;
Guid_names,window_name : TArrayOfString;
bool  : Boolean;
const AppName='{5E012E21-42EE-4840-A000-35F9FAB886E9}_is1';

{程序安装前判断主程序是否在运行}
function InitializeSetup(): Boolean;
var
  ResultCode: Integer;
begin
  if RegGetSubkeyNames(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',Guid_names) then
  begin
    for I:=0 to GetArrayLength(Guid_names)-1 do
    begin
      S := Guid_names[i];
      //注册表中找到了此键
      if AppName=Guid_names[i] then
      begin
        bool := RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'+S,'UninstallString',ResultStr);
        //ResultStr := RemoveQuotes(ResultStr);
        if bool then
        begin
          if MsgBox('安装程序检测到当前计算机已经安装了AIS客户端。' #13#13 '您是否要卸载AIS客户端?',  mbConfirmation, MB_YESNO) = IDYES then
            //   ShellExec('', ExpandConstant('{app}\unins000.exe'), '','', SW_SHOW, ewNoWait, ResultCode);
            begin
              Exec(RemoveQuotes(ResultStr), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
              Result := false;
            end
        end
        break;
      end
      else
      //zdx 5.8 判断是否已经打开了一个安装程序
      begin
        if FindWindowbyWindowName('安装 - AIS_Client')<>0 then
        begin
          MsgBox('安装程序检测到有另外一个安装程序已经在运行了', mbConfirmation, MB_OK);
          Result := false;
          break;
        end
      end
    end;
    if I= GetArrayLength(Guid_names) then
      Result := true;
  end
  else
    Result := true;
end;

//当用户单击cancel的时候,删除掉拷贝到系统的文件夹
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
end ;

//卸载密码验证函数
function AskPassword(): Boolean;
var
   Form: TSetupForm;
   OKButton, CancelButton: TButton;
   PwdEdit: TPasswordEdit;
begin
   Result := false;
   Form := CreateCustomForm();
   try
Form.ClientWidth := ScaleX(256);
Form.ClientHeight := ScaleY(100);
Form.Caption := '密码验证';
Form.BorderIcons := [biSystemMenu];
Form.BorderStyle := bsDialog;
Form.Center;

OKButton := TButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 50);
OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton.Caption := '确定';
OKButton.ModalResult := mrOk;
OKButton.Default := true;

CancelButton := TButton.Create(Form);
CancelButton.Parent := Form;
CancelButton.Width := ScaleX(75);
CancelButton.Height := ScaleY(23);
CancelButton.Left := Form.ClientWidth - ScaleX(75 + 50);
CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
CancelButton.Caption := '取消';
CancelButton.ModalResult := mrCancel;
CancelButton.Cancel := True;

PwdEdit := TPasswordEdit.Create(Form);
PwdEdit.Parent := Form;
PwdEdit.Width := ScaleX(210);
PwdEdit.Height := ScaleY(23);
PwdEdit.Left := ScaleX(23);
PwdEdit.Top := ScaleY(23);

Form.ActiveControl := PwdEdit;

if Form.ShowModal() = mrOk then
begin
   Result := PwdEdit.Text = 'bw12345678';
   if not Result then
         MsgBox('密码错误', mbInformation, MB_OK);
end;
   finally
Form.Free();
   end;
end;

//卸载程序的时候判断是否在运行
function InitializeUninstall(): Boolean;
begin
  begin
  //密码验证
  //Result :=  AskPassword();
  Result := TRUE;
//  DelTree(ExpandConstant('{app}\*'), False, True, True);
  end
end;

//提示卸载完后重启计算机
function UninstallNeedRestart(): Boolean;
begin
   Result := False;
   DelTree(ExpandConstant('{app}\*'), False, True, True);
   DelTree(ExpandConstant('{app}'), True, True, True);
end;

示例2(windows service,服务端安装):

;{089D6802-6CD3-4E45-B8D5-AC9ED99CE371}; 脚本由 Inno Setup 脚本向导生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{D0D0B722-C6F9-4A89-AB56-1417B9BD1400}
AppName=AIS_Server
AppVerName=AIS_Server
AppPublisher=公司名

DefaultDirName={pf}\AIS_Server
DefaultGroupName=AIS_Server
OutputBaseFilename=AIS_Server
Compression=lzma
SolidCompression=yes
SetupIconFile=D:\AIS\AIS 打包程序\AISGUI.ico
LicenseFile=C:\Documents and Settings\Administrator\桌面\许可协议.txt

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

[Files]
Source: "D:\AIS\AIS 打包程序\AIS_server_exe\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用"Flags: ignoreversion"

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

[Icons]
Name: "{group}\AIS服务端参数配置工具"; Filename: "{app}\ServiceConfig.exe"
;Name: "{group}\AIS客户端"; Filename: "{app}\AIS_client_exe\AISGUI.exe"
;Name: "{group}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"
;在开始菜单->所有程序->伴网书童里添加一个删除快捷键。
Name: "{group}\卸载"; Filename: {uninstallexe}
;Name: "{commondesktop}\AIS客户端"; Filename: "{app}\AIS_client_exe\AISGUI.exe"; Tasks: desktopicon
;Name: "{commondesktop}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"; Tasks: desktopicon

[Run]
;Filename: "{app}\Access_server\SecurityWare.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec
;Filename: "{app}\AIS_client_exe\AISGUI.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec

[Registry]
;添加开机启动
;Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName:"bwqc"; ValueData:"{app}\MSrv.exe";  Flags:uninsdeletevalue

[Code]
{卸载时判断主程序是否在运行}
var
is_Sys , is_value: integer;
S_syschar, S_currentchar, S_current,S_sys, S,ResultStr : string;
I ,CloseNum: Integer;
ErrorCode: Integer;
Guid_names,window_name : TArrayOfString;
bool  : Boolean;
const AppName='{D0D0B722-C6F9-4A89-AB56-1417B9BD1400}_is1';

{程序安装前判断主程序是否在运行}
function InitializeSetup(): Boolean;
var
  ResultCode: Integer;
begin
  if RegGetSubkeyNames(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',Guid_names) then
  begin
    for I:=0 to GetArrayLength(Guid_names)-1 do
    begin
      S := Guid_names[i];
      //注册表中找到了此键
      if AppName = Guid_names[i] then
      begin
        bool := RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'+S,'UninstallString',ResultStr);
        //ResultStr := RemoveQuotes(ResultStr);
        if bool then
        begin
           if MsgBox('安装程序检测到当前计算机已经安装了AIS_Server。' #13#13 '您是否要卸载AIS_Server?',  mbConfirmation, MB_YESNO) = IDYES then
            //   ShellExec('', ExpandConstant('{app}\unins000.exe'), '','', SW_SHOW, ewNoWait, ResultCode);
            begin
              Exec(RemoveQuotes(ResultStr), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
              Result := false;
            end
        end
        break;
      end
      else
      //zdx 5.8 判断是否已经打开了一个安装程序
      begin
        if FindWindowbyWindowName('安装 - AIS_Server')<>0 then
        begin
          MsgBox('安装程序检测到有另外一个安装程序已经在运行了', mbConfirmation, MB_OK);
          Result := false;
          break;
        end
      end
    end;
    if I = GetArrayLength(Guid_names) then
      Result := true;
  end
  else
    Result := true;
end;

//当用户单击cancel的时候,删除掉拷贝到系统的文件夹
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
end ;

//卸载密码验证函数
function AskPassword(): Boolean;
var
   Form: TSetupForm;
   OKButton, CancelButton: TButton;
   PwdEdit: TPasswordEdit;
begin
   Result := false;
   Form := CreateCustomForm();
   try
Form.ClientWidth := ScaleX(256);
Form.ClientHeight := ScaleY(100);
Form.Caption := '密码验证';
Form.BorderIcons := [biSystemMenu];
Form.BorderStyle := bsDialog;
Form.Center;

OKButton := TButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 50);
OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton.Caption := '确定';
OKButton.ModalResult := mrOk;
OKButton.Default := true;

CancelButton := TButton.Create(Form);
CancelButton.Parent := Form;
CancelButton.Width := ScaleX(75);
CancelButton.Height := ScaleY(23);
CancelButton.Left := Form.ClientWidth - ScaleX(75 + 50);
CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
CancelButton.Caption := '取消';
CancelButton.ModalResult := mrCancel;
CancelButton.Cancel := True;

PwdEdit := TPasswordEdit.Create(Form);
PwdEdit.Parent := Form;
PwdEdit.Width := ScaleX(210);
PwdEdit.Height := ScaleY(23);
PwdEdit.Left := ScaleX(23);
PwdEdit.Top := ScaleY(23);

Form.ActiveControl := PwdEdit;

if Form.ShowModal() = mrOk then
begin
   Result := PwdEdit.Text = 'bw12345678';
   if not Result then
         MsgBox('密码错误', mbInformation, MB_OK);
end;
   finally
Form.Free();
   end;
end;

procedure CurStepChanged(CurStep: TSetupStep);//添加环境变量
var
  ResultCode: Integer;
begin
if CurStep = ssPostInstall  then
 begin
     ShellExec('', ExpandConstant('{app}\ServiceInstall.exe'),
                '-is AIS_server "'+ ExpandConstant('{app}\AIS_server.exe')+'"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
 end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  ResultCode: Integer;
begin
  if CurUninstallStep = usUninstall then
    begin
       ShellExec('', ExpandConstant('{app}\ServiceInstall.exe'),
          '-u AIS_server "'+ ExpandConstant('{app}\AIS_server.exe')+'"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
   end;
end;

//卸载程序的时候判断是否在运行
function InitializeUninstall(): Boolean;
begin
  begin
  //密码验证
  //Result :=  AskPassword();
  Result := TRUE;
//  DelTree(ExpandConstant('{app}\*'), False, True, True);
  end
end;

//提示卸载完后重启计算机
function UninstallNeedRestart(): Boolean;
begin
   Result := False;
   DelTree(ExpandConstant('{app}\*'), False, True, True);
   DelTree(ExpandConstant('{app}'), True, True, True);
end;

Original: https://www.cnblogs.com/MaxWoods/p/4121701.html
Author: Max Woods
Title: 用inno Setup做应用程序安装包的示例脚本(.iss文件)(

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/552616/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • numpy中矩阵的逆,求解,特征值,特征向量

    逆:numpy.linalg.inv() 求矩阵的逆import numpy as npa=np.mat(‘1 0;0 1’)#生成一个矩阵print(ty…

    技术杂谈 2023年7月24日
    068
  • 平台指运行环境提供的能力的集合

    平台指运行环境提供的能力的集合 平台的一致性保证里服务的明确和统一,进而支持平台的复用和维护 一个人最好的习惯是独立思考、全面思考、深度思考、勤于思考、理性冷静、静坐沉思、定时反思…

    技术杂谈 2023年5月31日
    086
  • [学习笔记]Java正则表达式

    正则表达式 正则表达式定义了字符串的模式,可以用于搜索、编辑或处理文本; 正则表达式使用字符串描述规则,并用于匹配字符串; 一个正则表达式其实就是一个描述规则的字符串,被正则表达式…

    技术杂谈 2023年7月24日
    050
  • 使用MindSpore计算旋转矩阵

    坐标变换、旋转矩阵,是在线性空间常用的操作,在分子动力学模拟领域有非常广泛的应用。比如在一个体系中切换坐标,或者对整体分子进行旋转平移等。如果直接使用Numpy,是很容易可以实现的…

    技术杂谈 2023年7月25日
    052
  • Html转换PDF(Java实用版)

    前言: 在工作当中,遇到了需要把HTML页面转化为PDF文档,有很多中实现,如下进行一个对比,大家个借鉴去进行使用 各实现对比表 于Windows平台进行测试: 此博客仅基于ITe…

    技术杂谈 2023年6月21日
    095
  • 编程过程中常用的英文单词

    引用 parameter和argument的区别 parameter和argument的区别 parameter是指函数定义中参数,而argument指的是函数调用时的实际参数。 …

    技术杂谈 2023年6月21日
    076
  • List的同步类比较

    TL;NRs CopyOnWriteArrayList类在多线程顺序读取上有很大的优势,但在随机读取上反而有较大的劣势,且在写入方面性能极差。 Vector类在顺序读取方面性能较差…

    技术杂谈 2023年7月24日
    065
  • 「游记」NOIP2021爆零记

    欧拉欧拉欧拉欧拉欧拉欧拉欧拉欧拉,第一次参加 (NOIP),欧拉欧拉欧拉欧拉欧拉欧拉欧拉欧拉。 第一题比较简单,用类似于筛质数的做法即可,鉴于 CSP-S 的 (T1) 写挂,这从…

    技术杂谈 2023年7月24日
    058
  • java内存区域模型和详解

    一,概述 java虚拟机运行时数据区模型图: 主要包括:程序计数器,java虚拟机栈,本地方法栈,java 堆,方法区(元空间)。 其中堆和方法区由所有线程共享的数据区;程序计数器…

    技术杂谈 2023年7月11日
    069
  • Nginx配置中遇到到的问题和解决方案

    关于Nginx配置中遇到到的问题和解决方案 整理知识,学习笔记 Nginx配置别名(alias)及PHP解析 Nginx配置别名(alias)及PHP解析。 语法规则: locat…

    技术杂谈 2023年7月11日
    072
  • Swift对比Dart

    Dart、Swift 目前是开发用的比较多的语言,他们都是比较现代化的语言,在语法方面都比较像,本文会对其语言进行一下对比,便于记忆和语言过渡。本次的对比是基于最新Dart和Swi…

    技术杂谈 2023年6月1日
    070
  • Docker 部署 Kibana

    Docker 部署 Kibana 本篇主要介绍 使用 Docker 部署 kibana 用于操作 Elasticsearch 使用. 1. 前置准备 1.1 Elasticsear…

    技术杂谈 2023年7月10日
    058
  • vnpy源码阅读学习(4):自己写一个类似vnpy的UI框架

    自己写一个类似vnpy的界面框架 概述 通过之前3次对vnpy的界面代码的研究,我们去模仿做一个vn.py的大框架。巩固一下PyQt5的学习。 这部分的代码相对来说没有难度和深度,…

    技术杂谈 2023年7月11日
    092
  • Redis和Mysql保持数据一致性

    1、简述 在高并发的场景下,大量的请求直接访问Mysql很容易造成性能问题。所以,我们都会用Redis来做数据的缓存,削减对数据库的请求。但是,Mysql和Redis是两种不同的数…

    技术杂谈 2023年6月21日
    081
  • Redis变慢?深入浅出Redis性能诊断系列文章(四)

    (本文首发于”数据库架构师”公号,订阅”数据库架构师”公号,一起学习数据库技术,助力职业发展) 本篇为Redis性能问题诊断系列的第…

    技术杂谈 2023年7月25日
    068
  • 测试用例设计的底层逻辑

    转载请注明出处❤️ 作者:测试蔡坨坨 原文链接:caituotuo.top/aa1e1162.html 你好,我是测试蔡坨坨。 众所周知,测试用例是每个测试人员都绕不开的话题,也是…

    技术杂谈 2023年7月11日
    060
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球