Inno Setup打包工具例程

 

目录

一、前言

二、效果展示

三、教程&源码

四、Demo/相关包


 

一、前言

InnoSetup 是一个免费的 Windows 安装程序制作软件,简单的说,就是打包程序给用户安装。

 

二、效果展示

...

 

三、教程&源码

1. 打开编辑器,Inno Setup 5\Inno Setup 5\Compil32.exe

2. 编辑器->文件->打开,打开Inno Setup 5\setup.iss,可看到代码如下

; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName         "CTest1"
#define APP_FOLDER_NAME   "CTest1"
#define MyAppPublisher 	  "YJJ"
#define MyAppDate         "2020-04-21"
#define MyAppURL          "https://www.stu.edu.cn/"
#define MyAppExeName 	  "CTest1.exe"

#define VERSION_MAJOR       1
#define VERSION_MINOR       0
#define VERSION_SUBVRN      0
#define VERSION_REVISION    1
#define VERSION_SETUP       "setup"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,打开Inno Setup 5\Inno Setup 5\Compil32.exe 工具|在IDE中生成GUID。)
AppId={{7380C08E-B23A-4857-9423-F83C12415562}
;应用程序名称
AppName={#MyAppName}
;应用程序版本
AppVersion={#VERSION_MAJOR}.{#VERSION_MINOR}.{#VERSION_SUBVRN}.{#VERSION_REVISION}
;发布者信息
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#APP_FOLDER_NAME}
;创建开始菜单快捷方式文件夹名称
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
InfoBeforeFile=Readme.txt
;程序安装包输出路径
OutputDir=./
;安装和应用图标
SetupIconFile=./main.ico
WizardImageFile=./wizard.bmp
WizardSmallImageFile=./small.bmp
Compression=lzma
SolidCompression=yes
;程序安装包输出名称
OutputBaseFilename={#MyAppName}{#VERSION_MAJOR}.{#VERSION_MINOR}.{#VERSION_SUBVRN}.{#VERSION_REVISION}{#VERSION_SETUP}  
ShowUndisplayableLanguages = yes      
      
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "chinesesimp"; MessagesFile: "compiler:Languages\Chinesesimp.isl"
Name: "ChineseTrad"; MessagesFile: "compiler:Languages\ChineseTrad.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"  
              
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone;

[Files]
;制作安装包的主执行文件所在位置
Source: "..\CTest1\CTest1.exe"; DestDir:"{app}"; Flags:ignoreversion
;制作安装包的目录文件夹所在位置
Source: "..\CTest1\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”


[Icons]
;开始菜单快捷方式主程序名称
Name: "{group}\{#MyAppName}"; Filename: "{app}/{#MyAppExeName}"
;开始菜单快捷方式卸载名称
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
;桌面快捷方式名称
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}/{#MyAppExeName}"; Tasks: desktopicon; WorkingDir: "{app}"

[Run]
;安装完毕后提示是否运行的项目名称
Filename: "{app}/{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

代码比较简单,可自行阅览。

如果需要改图标,还需自行替换文件main.ico,small.bmp,wizard.bmp,这里值得注意的是,请在网上使用工具转换为相关的文件,不能自行改后缀,否则格式不符合会报错。

例如本机是small.jpg文件,自行修改名称为small.bmp,编译后运行会找不到图片报错。

 

修改完毕后,点击菜单栏编译图标,即可在文件夹生成相关安装包

这就是打包后的安装包。

 

四、Demo/相关包

另附Inno Setup5软件和Demo供大家参考(百度云盘):

链接:https://pan.baidu.com/s/15qk40VjVoBJVSMa8pfZHfg 
提取码:89y9

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用Inno Setup打包MySQL 8.0.30,首先需要下载MySQL的安装程序和Inno Setup软件。 1. 下载MySQL 8.0.30安装程序:进入MySQL官方网站,找到下载页面,下载MySQL 8.0.30的安装程序。保存到本地目录。 2. 下载Inno Setup软件:进入Inno Setup的官方网站,找到下载页面,下载最新版本的Inno Setup软件。保存到本地目录,并安装在你的电脑上。 3. 创建Inno Setup脚本文件:使用文本编辑器,新建一个空的文本文件。将以下代码复制到该文件中: ``` [Setup] AppName=MySQL 8.0.30 AppVersion=8.0.30 DefaultDirName={pf}\MySQL\MySQL Server 8.0 DefaultGroupName=MySQL AllowNoIcons=yes OutputDir=userdocs:Inno Setup Examples Output [Files] Source: "C:\path\to\mysql-8.0.30-installer.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall [Run] Filename: "{tmp}\mysql-8.0.30-installer.exe"; Parameters: "--install-server"; WorkingDir: "{tmp}"; StatusMsg: "Installing MySQL 8.0.30, please wait..." [UninstallDelete] Type: files; Name: "{app}\unins000.dat" Type: files; Name: "{app}\unins000.exe" [Tasks] Name: "desktopicon"; Description: "Create a desktop icon"; GroupDescription: "Additional tasks:"; Flags: unchecked [Icons] Name: "{commondesktop}\MySQL 8.0.30"; Filename: "{app}\{#MyAppExeName}" [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent ``` 4. 修改脚本文件中的路径:将代码中的"C:\path\to\mysql-8.0.30-installer.exe"修改为你自己保存MySQL安装程序的路径。 5. 保存脚本文件:将该文本文件保存为任意名称的脚本文件,并将文件后缀改为.iss。 6. 编译安装程序:在Inno Setup安装目录中,找到并运行Inno Setup编译器(iscc.exe)。在编译器中选择刚才保存的脚本文件,并点击编译按钮。将会生成一个名为setup.exe的安装程序。 7. 运行安装程序:双击生成的setup.exe文件,按照安装程序的提示和选项进行MySQL的安装。 通过以上步骤,你就可以使用Inno Setup打包MySQL 8.0.30,并生成一个可执行的安装程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值