Inno Setup 编译器打包多个exe和msi作为组件安装包的代码
程序员文章站
2024-02-06 23:04:34
...
Inno Setup 编译器打包多个exe和msi作为组件安装包的代码。效果如图:
脚本代码如下:
//创建于2020/11/27 www.baihang.design
[Setup]
#define MyAppName "XXX"
#define MyAppVersion "1.0.0.1"
#define MyAppPublisher "xxxxxx"
#define MyAppURL "http://www.baihang.desig"
#define MyAppExeName "XXX.exe"
#define AppSupportURL "www.baihang.design"
//定义安装包信息
AppId={{47A165D0-6237-4B7D-915E-4C3779A70F93}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
LicenseFile={#file AddBackslash(SourcePath) + "soft\License.txt"}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName=RVIPlatform
DisableProgramGroupPage=yes
OutputBaseFilename=Install
OutputDir=C:\Users\lbwslzx\Desktop\Output
SetupIconFile=C:\Users\lbwslzx\Desktop\soft\installlogo.ico
//Uninstallable=yes
//UninstallDisplayName=卸载{#MyAppName}
//UninstallDisplayIcon=C:\Users\lbwslzx\Desktop\soft\uninstalllogo.ico
Compression=lzma
SolidCompression=yes
PrivilegesRequired=userappdata
WizardStyle=modern
VersionInfoCopyright=Copyright (C) 2020-2021 深圳市罗博威视科技有限公司
//安装语言
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
//创建附加任务
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
//组件安装方式
[Types]
Name: win32; Description: Window_32位 默认环境组件安装
Name: win64; Description: Window_64位 默认环境组件安装;
Name: custom; Description: 自定义环境组件安装; Flags: iscustom
//组件列表选择项
[Components]
Name: MainApp; Description: XXX主程序-1.0.0.1-Window_32位&Window_64位; Types: win32 win64 custom ; Flags: fixed
Name: halcon; Description: Halcon10.0-Window_32位&Window_64位; Types: win32 win64 custom
Name: halcon\halconlicense; Description:将license秘钥文件注入Halcon10.0 ; Types: win32 win64 custom;Flags: exclusive
Name: "vcdll"; Description: "Microsoft Visual VS C++2012 运行库"; Types: win32 win64 custom
Name: vcdll/vcdll32; Description: Microsoft Visual VS C++2012 运行库-Window_32位; Types: win32 custom;Flags: exclusive
Name: vcdll/vcdll64; Description: Microsoft Visual VS C++2012 运行库-Window_64位; Types: win64 custom;Flags: exclusive
Name: mariadb; Description: Mariadb-10.0.14-Window_32位&Window_64位; Types: win32 win64 custom
Name: mysql; Description: Mysql-Connector-ODBC-5.1.5-Window_32位&Window_64位; Types: win32 win64 custom
Name: "dbsql"; Description: "导入数据包脚本"; Types: win32 win64 custom
Name: dbsql/dbsql32; Description: 执行导入数据包脚本-Window_32位; Types: win32 custom;Flags: exclusive
Name: dbsql/dbsql64; Description: 执行导入数据包脚本-Window_64位; Types: win64 custom;Flags: exclusive
//Name: readme\en; Description: 载入数据示例包; Flags: exclusive
//Name: readme\de; Description: 不载入数据示例包; Flags: exclusive
//源文件所在目录
[Files]
Source: "C:\Users\lbwslzx\Desktop\soft\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\lbwslzx\Desktop\XXX\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\lbwslzx\Desktop\soft\vcredist32.exe"; DestDir: "{app}"; Flags: recursesubdirs ; Components: vcdll/vcdll32; AfterInstall: vcdll32
Source: "C:\Users\lbwslzx\Desktop\soft\vcredist64.exe"; DestDir: "{app}"; Flags: recursesubdirs ; Components: vcdll/vcdll64; AfterInstall: vcdll64
Source: "C:\Users\lbwslzx\Desktop\soft\mariadb.msi"; DestDir: "{app}"; Flags: recursesubdirs ; Components: mariadb; AfterInstall: mariadb
Source: "C:\Users\lbwslzx\Desktop\soft\mysql.msi"; DestDir: "{app}"; Flags: ignoreversion ; Components: mysql; AfterInstall: mysql
Source: "C:\Users\lbwslzx\Desktop\soft\sql32.bat"; DestDir: "{app}"; Flags: recursesubdirs ; Components: dbsql/dbsql32; AfterInstall: dbsql32
Source: "C:\Users\lbwslzx\Desktop\soft\sql64.bat"; DestDir: "{app}"; Flags: recursesubdirs ; Components: dbsql/dbsql64; AfterInstall: dbsql64
Source: "C:\Users\lbwslzx\Desktop\soft\halcon\install-windows\setup.exe"; DestDir: "{app}"; Flags: recursesubdirs ; Components: halcon; AfterInstall: halcon
Source: "C:\Users\lbwslzx\Desktop\soft\halcon\license.exe"; DestDir: "{app}"; Flags: recursesubdirs ; Components: halcon\halconlicense; AfterInstall: halconlicense
Source: "C:\Users\lbwslzx\Desktop\XXX\XXX.exe"; DestDir: "{app}"; Flags: recursesubdirs; Components: MainApp
//图标及快捷项
[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: {group}\卸载 {#MyAppName}; Filename:{uninstallexe}; WorkingDir: {app}; Tasks: quicklaunchicon
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";Tasks: quicklaunchicon
Name: "{group}\加密狗远程升级工具"; Filename: "{app}\ukeyupdate.exe"; Tasks: quicklaunchicon
Name: "{group}\RVIPlatform操作文档"; Filename: "{app}\help\help.chm"; Tasks: quicklaunchicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
//执行项
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
//延伸代码
[CODE]
//默认选中同意软件协议
procedure InitializeWizard();
begin
WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
end;
//安装halcon
procedure halcon;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\halcon\install-windows\setup.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;
//安装vcdll32
procedure vcdll32;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\vcredist32.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;
//安装vcdll64
procedure vcdll64;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\vcredist64.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;
//安装mariadb
procedure mariadb;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\mariadb.msi'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;
//安装mysql
procedure mysql;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\mysql.msi'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;
//sql32
procedure dbsql32;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\sql32.bat'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;
//sql64
procedure dbsql64;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\sql64.bat'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;
//halconlicense
procedure halconlicense;
var
RetCode: integer;
begin
ShellExec('open', ExpandConstant('{app}\halcon\license.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode);
if RetCode <> 0 then
MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK);
end;