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

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

  1. ;{089D6802-6CD3-4E45-B8D5-AC9ED99CE371}; 脚本由 Inno Setup 脚本向导生成!
  2. ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
  3.  
  4. [Setup]
  5. ; 注: AppId的值为单独标识该应用程序。
  6. ; 不要为其他安装程序使用相同的AppId值。
  7. ; (生成新的GUID,点击 工具|在IDE中生成GUID。)
  8. AppId={{5E012E21-42EE-4840-A000-35F9FAB886E9}
  9. AppName=AIS_Client
  10. AppVerName=AIS_Client
  11. AppPublisher=公司名
  12.  
  13. DefaultDirName={pf}\AIS_Client
  14. DefaultGroupName=AIS_Client
  15. OutputBaseFilename=AIS_Client
  16. Compression=lzma
  17. SolidCompression=yes
  18. SetupIconFile=D:\AIS\AIS 打包程序\AISGUI.ico
  19. LicenseFile=C:\Documents and Settings\Administrator\桌\许可协议.txt
  20.  
  21. [Languages]
  22. Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
  23.  
  24. [Files]
  25. Source: "D:\AIS\AIS 打包程序\AIS_client_exe\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
  26. ; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion
  27.  
  28. [Tasks]
  29. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
  30.  
  31. [Icons]
  32. Name: "{group}\AIS客户端"; Filename: "{app}\AISGUI.exe"
  33. Name: "{group}\AIS客户端参数配置工具"; Filename: "{app}\ClientConfig.exe"
  34. Name: "{group}\AIS服务设置工具"; Filename: "{app}\ServiceIPManage.exe"
  35. Name: "{group}\AIS数据库参数配置工具"; Filename: "{app}\DataBaseConfig.exe"
  36. ;Name: "{group}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"
  37. ;在开始菜单->所有程序->伴网书童里添加一个删除快捷键。
  38. Name: "{group}\卸载"; Filename: {uninstallexe}
  39. Name: "{commondesktop}\AIS客户端"; Filename: "{app}\AISGUI.exe"; Tasks: desktopicon
  40. ;Name: "{commondesktop}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"; Tasks: desktopicon
  41.  
  42. [Run]
  43. ;Filename: "{app}\Access_server\SecurityWare.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec
  44. Filename: "{app}\AISGUI.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec
  45.  
  46. [Registry]
  47. ;添加开机启动
  48. Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName:"ais"; ValueData:"{app}\AISGUI.exe"; Flags:uninsdeletevalue
  49.  
  50. [Code]
  51. {卸载时判断主程序是否在运行}
  52. var
  53. is_Sys , is_value: integer;
  54. S_syschar, S_currentchar, S_current,S_sys, S,ResultStr : string;
  55. I ,CloseNum: Integer;
  56. ErrorCode: Integer;
  57. Guid_names,window_name : TArrayOfString;
  58. bool : Boolean;
  59. const AppName='{5E012E21-42EE-4840-A000-35F9FAB886E9}_is1';
  60.  
  61. {程序安装前判断主程序是否在运行}
  62. function InitializeSetup(): Boolean;
  63. var
  64. ResultCode: Integer;
  65. begin
  66. if RegGetSubkeyNames(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',Guid_names) then
  67. begin
  68. for I:= to GetArrayLength(Guid_names)- do
  69. begin
  70. S := Guid_names[i];
  71. //注册表中找到了此键
  72. if AppName=Guid_names[i] then
  73. begin
  74. bool := RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'+S,'UninstallString',ResultStr);
  75. //ResultStr := RemoveQuotes(ResultStr);
  76. if bool then
  77. begin
  78. if MsgBox('安装程序检测到当前计算机已经安装了AIS客户端。' ## '您是否要卸载AIS客户端?', mbConfirmation, MB_YESNO) = IDYES then
  79. // ShellExec('', ExpandConstant('{app}\unins000.exe'), '','', SW_SHOW, ewNoWait, ResultCode);
  80. begin
  81. Exec(RemoveQuotes(ResultStr), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  82. Result := false;
  83. end
  84. end
  85. break;
  86. end
  87. else
  88. //zdx 5.8 判断是否已经打开了一个安装程序
  89. begin
  90. if FindWindowbyWindowName('安装 - AIS_Client')<> then
  91. begin
  92. MsgBox('安装程序检测到有另外一个安装程序已经在运行了', mbConfirmation, MB_OK);
  93. Result := false;
  94. break;
  95. end
  96. end
  97. end;
  98. if I= GetArrayLength(Guid_names) then
  99. Result := true;
  100. end
  101. else
  102. Result := true;
  103. end;
  104.  
  105. //当用户单击cancel的时候,删除掉拷贝到系统的文件夹
  106. procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
  107. begin
  108. end ;
  109.  
  110. //卸载密码验证函数
  111. function AskPassword(): Boolean;
  112. var
  113. Form: TSetupForm;
  114. OKButton, CancelButton: TButton;
  115. PwdEdit: TPasswordEdit;
  116. begin
  117. Result := false;
  118. Form := CreateCustomForm();
  119. try
  120. Form.ClientWidth := ScaleX();
  121. Form.ClientHeight := ScaleY();
  122. Form.Caption := '密码验证';
  123. Form.BorderIcons := [biSystemMenu];
  124. Form.BorderStyle := bsDialog;
  125. Form.Center;
  126.  
  127. OKButton := TButton.Create(Form);
  128. OKButton.Parent := Form;
  129. OKButton.Width := ScaleX();
  130. OKButton.Height := ScaleY();
  131. OKButton.Left := Form.ClientWidth - ScaleX( + + + );
  132. OKButton.Top := Form.ClientHeight - ScaleY( + );
  133. OKButton.Caption := '确定';
  134. OKButton.ModalResult := mrOk;
  135. OKButton.Default := true;
  136.  
  137. CancelButton := TButton.Create(Form);
  138. CancelButton.Parent := Form;
  139. CancelButton.Width := ScaleX();
  140. CancelButton.Height := ScaleY();
  141. CancelButton.Left := Form.ClientWidth - ScaleX( + );
  142. CancelButton.Top := Form.ClientHeight - ScaleY( + );
  143. CancelButton.Caption := '取消';
  144. CancelButton.ModalResult := mrCancel;
  145. CancelButton.Cancel := True;
  146.  
  147. PwdEdit := TPasswordEdit.Create(Form);
  148. PwdEdit.Parent := Form;
  149. PwdEdit.Width := ScaleX();
  150. PwdEdit.Height := ScaleY();
  151. PwdEdit.Left := ScaleX();
  152. PwdEdit.Top := ScaleY();
  153.  
  154. Form.ActiveControl := PwdEdit;
  155.  
  156. if Form.ShowModal() = mrOk then
  157. begin
  158. Result := PwdEdit.Text = 'bw12345678';
  159. if not Result then
  160. MsgBox('密码错误', mbInformation, MB_OK);
  161. end;
  162. finally
  163. Form.Free();
  164. end;
  165. end;
  166.  
  167. //卸载程序的时候判断是否在运行
  168. function InitializeUninstall(): Boolean;
  169. begin
  170. begin
  171. //密码验证
  172. //Result := AskPassword();
  173. Result := TRUE;
  174. // DelTree(ExpandConstant('{app}\*'), False, True, True);
  175. end
  176. end;
  177.  
  178. //提示卸载完后重启计算机
  179. function UninstallNeedRestart(): Boolean;
  180. begin
  181. Result := False;
  182. DelTree(ExpandConstant('{app}\*'), False, True, True);
  183. DelTree(ExpandConstant('{app}'), True, True, True);
  184. end;

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

  1. ;{089D6802-6CD3-4E45-B8D5-AC9ED99CE371}; 脚本由 Inno Setup 脚本向导生成!
  2. ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
  3.  
  4. [Setup]
  5. ; 注: AppId的值为单独标识该应用程序。
  6. ; 不要为其他安装程序使用相同的AppId值。
  7. ; (生成新的GUID,点击 工具|在IDE中生成GUID。)
  8. AppId={{D0D0B722-C6F9-4A89-AB56-1417B9BD1400}
  9. AppName=AIS_Server
  10. AppVerName=AIS_Server
  11. AppPublisher=公司名
  12.  
  13. DefaultDirName={pf}\AIS_Server
  14. DefaultGroupName=AIS_Server
  15. OutputBaseFilename=AIS_Server
  16. Compression=lzma
  17. SolidCompression=yes
  18. SetupIconFile=D:\AIS\AIS 打包程序\AISGUI.ico
  19. LicenseFile=C:\Documents and Settings\Administrator\桌\许可协议.txt
  20.  
  21. [Languages]
  22. Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
  23.  
  24. [Files]
  25. Source: "D:\AIS\AIS 打包程序\AIS_server_exe\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
  26. ; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion
  27.  
  28. [Tasks]
  29. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
  30.  
  31. [Icons]
  32. Name: "{group}\AIS服务端参数配置工具"; Filename: "{app}\ServiceConfig.exe"
  33. ;Name: "{group}\AIS客户端"; Filename: "{app}\AIS_client_exe\AISGUI.exe"
  34. ;Name: "{group}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"
  35. ;在开始菜单->所有程序->伴网书童里添加一个删除快捷键。
  36. Name: "{group}\卸载"; Filename: {uninstallexe}
  37. ;Name: "{commondesktop}\AIS客户端"; Filename: "{app}\AIS_client_exe\AISGUI.exe"; Tasks: desktopicon
  38. ;Name: "{commondesktop}\门控服务端"; Filename: "{app}\Access_server\SecurityWare.exe"; Tasks: desktopicon
  39.  
  40. [Run]
  41. ;Filename: "{app}\Access_server\SecurityWare.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec
  42. ;Filename: "{app}\AIS_client_exe\AISGUI.exe"; Description: "{cm:LaunchProgram,AIS}"; Flags: nowait postinstall skipifsilent shellexec
  43.  
  44. [Registry]
  45. ;添加开机启动
  46. ;Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName:"bwqc"; ValueData:"{app}\MSrv.exe"; Flags:uninsdeletevalue
  47.  
  48. [Code]
  49. {卸载时判断主程序是否在运行}
  50. var
  51. is_Sys , is_value: integer;
  52. S_syschar, S_currentchar, S_current,S_sys, S,ResultStr : string;
  53. I ,CloseNum: Integer;
  54. ErrorCode: Integer;
  55. Guid_names,window_name : TArrayOfString;
  56. bool : Boolean;
  57. const AppName='{D0D0B722-C6F9-4A89-AB56-1417B9BD1400}_is1';
  58.  
  59. {程序安装前判断主程序是否在运行}
  60. function InitializeSetup(): Boolean;
  61. var
  62. ResultCode: Integer;
  63. begin
  64. if RegGetSubkeyNames(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',Guid_names) then
  65. begin
  66. for I:= to GetArrayLength(Guid_names)- do
  67. begin
  68. S := Guid_names[i];
  69. //注册表中找到了此键
  70. if AppName = Guid_names[i] then
  71. begin
  72. bool := RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'+S,'UninstallString',ResultStr);
  73. //ResultStr := RemoveQuotes(ResultStr);
  74. if bool then
  75. begin
  76. if MsgBox('安装程序检测到当前计算机已经安装了AIS_Server' ## '您是否要卸载AIS_Server', mbConfirmation, MB_YESNO) = IDYES then
  77. // ShellExec('', ExpandConstant('{app}\unins000.exe'), '','', SW_SHOW, ewNoWait, ResultCode);
  78. begin
  79. Exec(RemoveQuotes(ResultStr), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  80. Result := false;
  81. end
  82. end
  83. break;
  84. end
  85. else
  86. //zdx 5.8 判断是否已经打开了一个安装程序
  87. begin
  88. if FindWindowbyWindowName('安装 - AIS_Server')<> then
  89. begin
  90. MsgBox('安装程序检测到有另外一个安装程序已经在运行了', mbConfirmation, MB_OK);
  91. Result := false;
  92. break;
  93. end
  94. end
  95. end;
  96. if I = GetArrayLength(Guid_names) then
  97. Result := true;
  98. end
  99. else
  100. Result := true;
  101. end;
  102.  
  103. //当用户单击cancel的时候,删除掉拷贝到系统的文件夹
  104. procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
  105. begin
  106. end ;
  107.  
  108. //卸载密码验证函数
  109. function AskPassword(): Boolean;
  110. var
  111. Form: TSetupForm;
  112. OKButton, CancelButton: TButton;
  113. PwdEdit: TPasswordEdit;
  114. begin
  115. Result := false;
  116. Form := CreateCustomForm();
  117. try
  118. Form.ClientWidth := ScaleX();
  119. Form.ClientHeight := ScaleY();
  120. Form.Caption := '密码验证';
  121. Form.BorderIcons := [biSystemMenu];
  122. Form.BorderStyle := bsDialog;
  123. Form.Center;
  124.  
  125. OKButton := TButton.Create(Form);
  126. OKButton.Parent := Form;
  127. OKButton.Width := ScaleX();
  128. OKButton.Height := ScaleY();
  129. OKButton.Left := Form.ClientWidth - ScaleX( + + + );
  130. OKButton.Top := Form.ClientHeight - ScaleY( + );
  131. OKButton.Caption := '确定';
  132. OKButton.ModalResult := mrOk;
  133. OKButton.Default := true;
  134.  
  135. CancelButton := TButton.Create(Form);
  136. CancelButton.Parent := Form;
  137. CancelButton.Width := ScaleX();
  138. CancelButton.Height := ScaleY();
  139. CancelButton.Left := Form.ClientWidth - ScaleX( + );
  140. CancelButton.Top := Form.ClientHeight - ScaleY( + );
  141. CancelButton.Caption := '取消';
  142. CancelButton.ModalResult := mrCancel;
  143. CancelButton.Cancel := True;
  144.  
  145. PwdEdit := TPasswordEdit.Create(Form);
  146. PwdEdit.Parent := Form;
  147. PwdEdit.Width := ScaleX();
  148. PwdEdit.Height := ScaleY();
  149. PwdEdit.Left := ScaleX();
  150. PwdEdit.Top := ScaleY();
  151.  
  152. Form.ActiveControl := PwdEdit;
  153.  
  154. if Form.ShowModal() = mrOk then
  155. begin
  156. Result := PwdEdit.Text = 'bw12345678';
  157. if not Result then
  158. MsgBox('密码错误', mbInformation, MB_OK);
  159. end;
  160. finally
  161. Form.Free();
  162. end;
  163. end;
  164.  
  165. procedure CurStepChanged(CurStep: TSetupStep);//添加环境变量
  166. var
  167. ResultCode: Integer;
  168. begin
  169. if CurStep = ssPostInstall then
  170. begin
  171. ShellExec('', ExpandConstant('{app}\ServiceInstall.exe'),
  172. '-is AIS_server "'+ ExpandConstant('{app}\AIS_server.exe')+'"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  173. end;
  174. end;
  175.  
  176. procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
  177. var
  178. ResultCode: Integer;
  179. begin
  180. if CurUninstallStep = usUninstall then
  181. begin
  182. ShellExec('', ExpandConstant('{app}\ServiceInstall.exe'),
  183. '-u AIS_server "'+ ExpandConstant('{app}\AIS_server.exe')+'"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  184. end;
  185. end;
  186.  
  187. //卸载程序的时候判断是否在运行
  188. function InitializeUninstall(): Boolean;
  189. begin
  190. begin
  191. //密码验证
  192. //Result := AskPassword();
  193. Result := TRUE;
  194. // DelTree(ExpandConstant('{app}\*'), False, True, True);
  195. end
  196. end;
  197.  
  198. //提示卸载完后重启计算机
  199. function UninstallNeedRestart(): Boolean;
  200. begin
  201. Result := False;
  202. DelTree(ExpandConstant('{app}\*'), False, True, True);
  203. DelTree(ExpandConstant('{app}'), True, True, True);
  204. end;

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

  1. 用Inno Setup制作WEB程序安装包

    原文 用Inno Setup制作WEB程序安装包 最近做了一个WEB程序的安装包,我把制作的过程做个介绍,贴出源码给大家做个参考 看看inno 的脚本 [Setup] AppCopyright=tes ...

  2. Inno Setup制作应用程序安装包

    我最近写了一个MFC应用程序,想发给其他的小伙伴玩一玩,直接发了个exe文件过去,结果发现小伙伴那边打不开.原来这个exe文件虽然是MFC静态编译的,但是还依赖了其他几个.dll文件,需要把这几个dl ...

  3. [Azure DevOps] 使用 Inno Setup 制作桌面软件安装包

    1. 桌面应用程序的 CI/CD 桌面应用程序的 CI/CD 过程和网站有一些不同,毕竟桌面应用程序的"部署"只是将安装包分发到目标位置,连应用商店都不用上,根据公司的管理流程可以 ...

  4. 用inno Setup制作web项目安装包

    http://www.cnblogs.com/xionghui/archive/2012/03/22/2411207.html 用inno Setup制作安装包 新建一个文件夹exambody,放ap ...

  5. nsis安装包_示例脚本语法解析

    以下是代码及解析,其中有底色的部分为脚本内容. 注释.!define.变量.!include.常量 ; Script generated by the HM NIS Edit Script Wizar ...

  6. 【原创】VB6.0应用程序安装包的生成(Setup Factory 9.0制作安装包的方法)

    VB6.0应用程序安装包的生成,利用其自带的打包工具生成的安装程序很简陋,一点不美观:如果想让自己的应用程序安装的时候显得高大上一点,本教程提供使用Setup Factory 9.0制作安装包的方法. ...

  7. Mac OS平台下应用程序安装包制作工具Packages的使用介绍

    一.介绍 Windows下面开发好的应用程序要进行分发时有很多打包工具可供选择,如Inno Setup, InstallShield, NSIS, Advanced Installer, Qt Ins ...

  8. 使用Inno Setup 打包.NET程序,并自动安装.Net Framework

    使用Inno Setup 打包.NET程序,并自动安装.Net Framework http://www.cnblogs.com/xiaogangqq123/archive/2012/03/19/24 ...

  9. 【程序打包工具 Inno Setup】CreateProcess 失败:代码 740(Inno Setup打包的程序提升为管理员权限)

    原文参考 https://www.cnblogs.com/SnailProgramer/p/4243666.html http://blog.csdn.net/x356982611/article/d ...

随机推荐

  1. 自动布局之autoresizingMask

    UIViewAutoresizing是一个枚举类型,默认是UIViewAutoresizingNone,也就是不做任何处理. 1 2 3 4 5 6 7 8 9 typedef NS_OPTIONS( ...

  2. sessionFactory

    SessionFactory接口:SessionFactory接口负责初始化Hibernate.它充当数据存储源的代理,并负责创建Session对象.这里用到了工厂模式.需要注意的是SessionFa ...

  3. IIS访问提示您不具备查看该目录或页面的权限,因为访问控制列表 (ACL) 对 Web 服务器上的该资源进行了配置

    1. 检查IIS权限,webmail目录权限. 2. 在本地安全策略中,设置从网络访问本地服务器与拒绝从网络访问本地服务器.中查看相关用户的权限 3. 如果上面的步骤还是有问题.使用下面的步骤进行设置 ...

  4. Centos7 php 5.6.19编译安装

    0x01  前言 在php官网下载php-5.6.19.tar.gz源代码(php7虽然说性能提升很大,但是小菜菜还是先用着这个先吧),解压后根目录有个INSTALL文件,里面有安装教程了,目录如下: ...

  5. AutoResetEvent waitone set进一步理解补充

    AutoResetEvent 的定义 //定义两个信号锁 AutoResetEvent ReadTxt = new AutoResetEvent(false); AutoResetEvent Uplo ...

  6. 使用事件等待句柄EventWaitHandler 实现生产者、消费者队列

    using System; using System.Threading; using System.Collections.Generic; class ProducerConsumerQueue ...

  7. vi/vim学习

    1.vi3中模式 一般模式.编辑模式.命令模式2.快捷操作 i.I插入:i在目前的光标所在处插入文字:I(大写i)在行首插入 a.A 增加:a由光标所在的下一个字开始输入:A由光标所在行的最后增加 o ...

  8. c# 身份证证号验证方法

    #region 验证身份证是否有效        /// <summary>        /// 验证身份证是否有效        /// </summary>        ...

  9. 关于最近在做的一个js全屏轮播插件

    最近去面试了,对方要求我在一个星期内用原生的js代码写一个全屏轮播的插件,第一想法就是跟照片轮播很相似,只是照片轮播是有定义一个宽高度大小已经确定了的容器用来存储所有照片,然后将照片全部左浮动,利用m ...

  10. Setting SVN Repository Using TortoiseSVN + Dropbox in 5 Minutes

    SVN is a very common version control system in software development. However configuring SVN server ...