WindowsStarter/server/model/install-win7-model.iss

302 lines
9.1 KiB
Plaintext
Raw Normal View History

2025-08-17 13:51:37 +08:00
;iss
#define MyAppName "模型管理"
2025-08-18 17:19:16 +08:00
#define MyAppVersion "1.0.0"
2025-08-17 13:51:37 +08:00
#define MyAppPublisher "X"
#define MyAppURL "~"
#define MyAppExeName "model"
#define MyAppExeNameHump "Model"
#define MyAppExeNameUpper "MODEL"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
2025-08-18 13:03:52 +08:00
#define MyAppFirstPath "XManage"
#define MyAppResources "Resources"
#define InstallPassword GetDateTimeString('yyyymmdd', '', '')
2025-08-17 13:51:37 +08:00
; 默认配置
[Setup]
AppId={{A0EBDCA7-8C1A-43FD-BD3A-7E9E6D8B7F6C}
; 默认安装路径
2025-08-18 13:03:52 +08:00
DefaultDirName={localappdata}\{#MyAppFirstPath}
2025-08-17 13:51:37 +08:00
; 安装密码
2025-08-18 13:03:52 +08:00
Password={#InstallPassword}
2025-08-17 13:51:37 +08:00
; 是否加密
Encryption=yes
; ICO图标
2025-08-18 13:03:52 +08:00
;SetupIconFile={#MyAppResources}\icon.ico
2025-08-18 17:19:16 +08:00
VersionInfoProductVersion={#MyAppVersion}
2025-08-17 13:51:37 +08:00
VersionInfoCompany=
VersionInfoDescription={#MyAppName}服务
VersionInfoCopyright=CopyRight © 2025
VersionInfoProductName={#MyAppName}
; 默认配置
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
ChangesAssociations=yes
DisableDirPage=no
DisableProgramGroupPage=yes
Compression=lzma2
SolidCompression=yes
WizardStyle=modern
ChangesEnvironment=yes
PrivilegesRequired=admin
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
OutputDir=Release\
OutputBaseFilename={#MyAppExeNameHump}Setup-{#MyAppVersion}
UninstallFilesDir={app}\{#MyAppExeName}
UninstallDisplayIcon={app}\{#MyAppExeName}\{#MyAppExeName}.bat
2025-08-18 13:03:52 +08:00
2025-08-17 13:51:37 +08:00
; 语言选择
[Languages]
Name: "Chinese"; MessagesFile: "compiler:Languages\Chinese.isl"
2025-08-18 13:03:52 +08:00
2025-08-17 13:51:37 +08:00
;; 任务
[Tasks]
; 是否创建桌面图标
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
2025-08-18 13:03:52 +08:00
2025-08-17 13:51:37 +08:00
;; 程序 ICO
[Icons]
;Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}.exe"
;Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}.exe"; Tasks: desktopicon
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}\{#MyAppExeName}.bat"; Tasks: desktopicon
2025-08-18 13:03:52 +08:00
2025-08-17 13:51:37 +08:00
;; 组件安装方式
[Types]
; 完整安装所有组件
Name: full; Description: 完整组件安装;
Name: "mini"; Description: "最小安装";
; 自定义安装
Name: custom; Description: 自定义安装; Flags: iscustom
2025-08-18 13:03:52 +08:00
2025-08-17 13:51:37 +08:00
;; 组件列表选择项
[Components]
Name: Starter; Description: {#MyAppName} 启动; Types: full;
Name: UI; Description: {#MyAppName} UI; Types: full mini;
Name: Server; Description: {#MyAppName} Server; Types: full mini;
Name: Data; Description: {#MyAppName} Data; Types: full;
2025-08-18 13:03:52 +08:00
2025-08-17 13:51:37 +08:00
;; 安装包引入文件列表
[Files]
; 后端工程+启动器
2025-08-18 13:03:52 +08:00
;Source: "{#MyAppResources}\{#MyAppExeName}.exe"; DestDir: "{app}\{#MyAppExeName}"; Flags: ignoreversion; Components: Starter
;Source: "{#MyAppResources}\{#MyAppExeName}-console.exe"; DestDir: "{app}\{#MyAppExeName}"; Flags: ignoreversion; Components: Starter
;Source: "{#MyAppResources}\{#MyAppExeName}-x64.exe"; DestDir: "{app}\{#MyAppExeName}"; Flags: ignoreversion; Components: Starter
;Source: "{#MyAppResources}\{#MyAppExeName}-x86.exe"; DestDir: "{app}\{#MyAppExeName}"; Flags: ignoreversion; Components: Starter
;Source: "{#MyAppResources}\patch.exe"; DestDir: "{app}\{#MyAppExeName}"; Flags: ignoreversion; Components: Starter
2025-08-17 13:51:37 +08:00
2025-08-18 13:03:52 +08:00
Source: "{#MyAppResources}\{#MyAppExeName}.bat"; DestDir: "{app}\{#MyAppExeName}"; DestName: "{#MyAppExeName}.bat"; Flags: ignoreversion; Components: Starter
Source: "{#MyAppResources}\server\demo-0.0.1.jar"; DestDir: "{app}\{#MyAppExeName}\bin"; Flags: ignoreversion; Components: Server
2025-08-17 13:51:37 +08:00
; 更新数据库脚本
2025-08-18 13:03:52 +08:00
Source: "{#MyAppResources}\script\*"; DestDir: "{app}\{#MyAppExeName}\script"; Flags: ignoreversion recursesubdirs createallsubdirs; Components: Data
2025-08-17 13:51:37 +08:00
; 前端工程 + Nginx
2025-08-18 13:03:52 +08:00
Source: "{#MyAppResources}\web\*"; DestDir: "{app}\{#MyAppExeName}\web"; Flags: ignoreversion recursesubdirs createallsubdirs; Components: Starter;
Source: "{#MyAppResources}\dist\*"; DestDir: "{app}\{#MyAppExeName}\web\dist"; Flags: ignoreversion recursesubdirs createallsubdirs; Components: UI;
2025-08-17 13:51:37 +08:00
;; 创建必要目录
[Dirs]
Name: "{app}\{#MyAppExeName}\web\logs"; Permissions: users-modify; Components: Starter;
Name: "{app}\{#MyAppExeName}\web\temp"; Permissions: users-modify; Components: Starter;
2025-08-18 13:03:52 +08:00
2025-08-17 13:51:37 +08:00
;; 安装时注册表与环境变量列表
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; Flags: uninsdeletevalue; \
ValueName: "{#MyAppExeNameUpper}_MAIN"; ValueData: "{app}\{#MyAppExeName}";
; 启动jar
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; Flags: uninsdeletevalue; \
ValueName: "{#MyAppExeNameUpper}_MANAGE_BIN"; ValueData: "{app}\{#MyAppExeName}\bin\demo-0.0.1.jar";
; 扩展启动vm变量
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; Flags: uninsdeletevalue; \
ValueName: "{#MyAppExeNameUpper}_VM_PARAMS"; ValueData: " \
--enable-preview \
-Dserver.port=28680 \
-Dproject.database-ip=127.0.0.1 \
-Dproject.database-port=33306 \
-Dproject.database-name=model \
2025-08-17 18:51:49 +08:00
-Dmybatis-flex.datasource.ds1.username=model \
-Dmybatis-flex.datasource.ds1.password=Wfbke8!LeMY5Fwwe \
2025-08-17 13:51:37 +08:00
";
;; 安装完运行的菜单与后续操作
; [Run]
;; 安装完成后运行 startup.exe
; Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: postinstall runascurrentuser waituntilterminated skipifsilent hidewizard;
; Filename: "timeout"; Parameters: "/t 2 /nobreak >nul && {app}\{#MyAppExeName}.exe"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: postinstall runascurrentuser waituntilterminated skipifsilent hidewizard;
;; 自定义函数
[Code]
const
WM_SETTINGCHANGE = 26; // 0x001A 的十进制
SMTO_ABORTIFHUNG = 2; // 0x0002 的十进制
// 定义 VC++ 2019 运行时的注册表检查路径
VC2019_REDIST_X64 = '{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}';
VC2019_REDIST_X86 = '{422B21A3-06FA-3F2F-A6C6-21BCC9B8E2F3}';
2025-08-18 13:03:52 +08:00
// 获取安装密码
function GetInstallPassword(): string;
begin
Result := GetDateTimeString('yyyymmdd', '', '');
end;
2025-08-17 13:51:37 +08:00
function SendMessageTimeout(
hWnd: Integer;
Msg: Integer;
wParam: Integer;
lParamStr: String;
fuFlags: Integer;
uTimeout: Integer;
var lpdwResult: Integer
): Integer;
external 'SendMessageTimeoutW@user32.dll stdcall';
// 给 Path 系统环境变量追加环境
function NeedsAddPath(Param: string): boolean;
var
OrigPath: string;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OrigPath)
then begin
Result := True;
exit;
end;
// 检查路径是否已存在
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
if Result = True then
Result := Pos(';' + Param + '\;', ';' + OrigPath + ';') = 0;
end;
// 刷新系统环境
procedure RefreshEnvironment;
var
Res: Integer;
begin
SendMessageTimeout(
HWND_BROADCAST,
WM_SETTINGCHANGE,
0,
'Environment',
SMTO_ABORTIFHUNG,
5000,
Res
);
end;
// 检查环境变量,路径是否存在空格
function CheckRegistryPath(Path: string): Boolean;
begin
if Pos(' ', Path) > 0 then
begin
SuppressibleMsgBox('安装程序错误: 检测到无效的注册表路径 "' + Path + '"。路径不能包含空格。', mbCriticalError, MB_OK, IDOK);
Abort;
Result := False;
Exit;
end;
Result := True;
end;
// 以 UTF-8 写入文件
function SaveStringToUTF8File(const FileName, Content: String; Append: Boolean): Boolean;
var
UTF8Content: AnsiString;
begin
UTF8Content := UTF8Encode(Content);
Result := SaveStringToFile(FileName, UTF8Content, Append);
end;
// 检查是否已安装 VC++ 2019 运行时
function IsVC2019Installed: Boolean;
var
Version: String;
begin
// 检查64位版本
Result := RegQueryStringValue(
HKLM,
'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64',
'Version',
Version
) or RegKeyExists(
HKLM,
'SOFTWARE\Classes\Installer\Dependencies\' + VC2019_REDIST_X64
);
// 如果是32位系统或需要检查32位运行时
if not Result and (not IsWin64) then
Result := RegQueryStringValue(
HKLM,
'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86',
'Version',
Version
) or RegKeyExists(
HKLM,
'SOFTWARE\Classes\Installer\Dependencies\' + VC2019_REDIST_X86
);
end;
// 在安装前检查
function InitializeSetup: Boolean;
begin
// 默认允许安装继续
Result := True;
// 如果 VC++ 2019 未安装
if not IsVC2019Installed then
begin
MsgBox('本程序需要 Microsoft Visual C++ 2019 运行时才能继续1001', mbError, MB_OK)
// 中止安装
Result := False;
end;
end;
[UninstallRun]
Filename: "taskkill"; Parameters: "-f -im {#MyAppExeName}-web.exe"; Flags: runascurrentuser runhidden waituntilterminated
2025-08-17 19:40:26 +08:00
;; 卸载时删除的文件
[UninstallDelete]
Type: filesandordirs; Name: "{app}\{#MyAppExeName}\log"
Type: filesandordirs; Name: "{app}\{#MyAppExeName}\script"