安装
访问Inno Setup官网,下载最新版本innosetup-6.2.2.exe
,下载完成后双击安装,根据英文提示完成相应的配置,如图①、②、③、④、⑤、⑥,安装完成后打开

创建脚本
在打开的Welcome窗口,选择Create a new script file using Script Wizard
,然后点击OK

按照提示完成一步一步完成脚本参数配置,如下图①、② …… ⑬ 、⑭

按快捷键(Ctrl + F9)或者点击工具栏从左到右第四个图标,编译脚本,生成exe安装包

最终生成exe文件,这个安装包会带有向导脚本里边填写的信息,如版本号、公司、文件说明等

脚本解析
有了脚本以后直接修改脚本就可以了(按需修改),不用每次都要填写向导脚本的流程,这里介绍脚本一些关键的变量和参数
宏定义
以下宏定义用于定义程序名、软件版本、发布者、发布者网站信息、关联的文件格式等
1 2 3 4 5 6 7 8
| #define MyAppName "Example" #define MyAppVersion "1.0.0" #define MyAppPublisher "iotstuff" #define MyAppURL "https://iotstuff.cn" #define MyAppExeName "Example.exe" #define MyAppAssocName MyAppName + " File" #define MyAppAssocExt ".myp" #define MyAppAssocKey StringChange(MyAppAssocName, " ", ") + MyAppAssocExt
|
Setup
setup用于定义一些基本的软件包信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| AppId={{75FF5697-7D83-46D7-824A-F4259ADE4FC3} AppName={#MyAppName} AppVersion={#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={autopf}\{#MyAppName} ChangesAssociations=yes DisableProgramGroupPage=yes OutputDir=E:\ OutputBaseFilename=Example SetupIconFile=E:\logo.ico Compression=lzma SolidCompression=yes WizardStyle=modern
|
Languages
setup程序的默认语言设置
1
| Name: "english"; MessagesFile: "compiler:Default.isl"
|
Tasks
编译任务相关参数定义
1
| Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
Files
输出的exe压缩包路径定义
1 2
| Source: "E:\build\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion Source: "E:\build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
Registry
注册表相关信息,保存一些需要持久化的软件包信息
1 2 3 4 5
| 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
程序logo自定义
1 2
| Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
Run
可执行程序路径定义
1
| Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|