Skip to content

Innosetup

>

介绍了使用 Inno Setup 制作安装程序的方法, 安装程序的界面 支持多语言

1. 下载 Inno Setup

官网: https://jrsoftware.org/isinfo.php

本文以最新版本 6.2.2 为例

2. 新建安装程序脚本

选择要打包的程序文件

最终生成了编译脚本

3. 编译为安装程序

4. 加入 其它语言支持

https://jrsoftware.org/files/istrans/ 下载

5. 通过命令行生成 安装程序

csharp
set inno="C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
%inno%  setup.iss

6. 卸载应用

7. 游戏中 实现 静默安装 自动升级

csharp
setup.exe /silent /nocancel /closeapplications /dir=./

8. 脚本配置注意事项

  • PrivilegesRequired 需要给lowest,否则程序安装时会提示需要admin权限。
  • UsePreviousAppDir=no 这个安装时不会有上一次目录,每次都可以让用户选择
  • 安装程序和卸载程序图标(注意windows对图标有缓存,如果想测试不同图标,需要修改图标名字和程序名)

SetupIconFile ={#APP_SRC_PATH}icon.ico

效果如下:

8.1 开启uninstall日志

增加配置

UninstallLogMode=append

日志目录在c/user/{username}/appdata/local/temp

如下

8.2 删除文件:

csharp
[UninstallDelete]
Type: files; Name: "{app}\prefs.ini"
Type: filesandordirs; Name: "{app}\files"

或者

csharp
[Code]
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
  begin
    if CurUninstallStep=usDone then
      Log('The uninstall my is:' + ExpandConstant('{app}\files'));
      DelTree(ExpandConstant('{app}\files'),True,True,True);
  end;