inno setup执行带参数服务程序并启动服务

akiooo 2018-07-19 AM 506℃

以下是一个短小精悍型的打包程序,先记录下来,以备忘。

 

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

;是否安装驱动
#define IncludeDrive 0
#define IsExternal ""

;安装包exe的输出路径
#define OutPutDirectory "E:\项目\Zebra"

;组件驱动路径
#define MyInnoCommonDirectory "E:\项目\驱动"

;文件路径
#define MyFileDirectory "E:\Software\Codes\Trunk\ZebraControl\Bin"

;版本
#define version "0.1.12"

;程序名称
#define appname "Zebra"

;运行exe名称
#define MyAppExeName "BGI Sequence Control Software.exe"

;窗口名称
#define AppWindowName "BGI Sequence Control Software"

;程序运行提示
#define RunningNotice "安装程序检测到客户端正在运行,请先退出!"

;公司网站
#define MyAppURL "http://www.it.com"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{14A54E41-6A63-4842-A799-2D95BE9E60A0}
AppName={#appname}
AppVersion={#version}
AppVerName={#appname} {#version}
DefaultDirName={sd}\{#appname}
DefaultGroupName={#appname}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}

;输出目录
OutputDir={#OutPutDirectory}

;输出文件名
OutputBaseFilename={#appname} {#version}
Compression=lzma
SolidCompression=yes

VersionInfoVersion={#version}

;提示是否覆盖
DirExistsWarning = yes

;许可证说明
LicenseFile=compiler:license.txt

;很重要,将显示所有语言
ShowUndisplayableLanguages=yes

[Languages]
Name: "chs"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
Name: "eng"; MessagesFile: "compiler:Default.isl"

[Messages]
chs.BeveledLabel=Chinese
eng.BeveledLabel=English

[Tasks]
;创建桌面快捷方式,默认选中
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";

[Files]
;拷贝文件夹及子文件夹的所有文件
;Source: {#MyFileDirectory}\*.lib; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: {#MyFileDirectory}\*.dll; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: {#MyFileDirectory}\*.exe; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: {#MyFileDirectory}\Config\*.txt; DestDir: "{app}\Config"; Flags: onlyifdoesntexist
Source: {#MyFileDirectory}\Log\*.db; DestDir: "{app}\Log"; Flags: onlyifdoesntexist
Source: {#MyFileDirectory}\Recipe\*.xml; DestDir: "{app}\Recipe"; Flags: onlyifdoesntexist

; NOTE: Don't use "Flags: ignoreversion" on any shared system files
;安装驱动,不需要打包,先放到临时目录下
#if IncludeDrive
Source: "{#MyInnoCommonDirectory}\driv_win_smart_v1.22_build_14030711_whql\disk.x64\mxspinst.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
Source: "{#MyInnoCommonDirectory}\PCO相机驱动\DI_USB3_WXP_W7_W8_V109.EXE"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
Source: "{#MyInnoCommonDirectory}\RENESAS-USB3-Host-Driver\RENESAS-USB3-Host-Driver-30200-setup.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
Source: "{#MyInnoCommonDirectory}\camware\SW_CAMWAREWIN64_316.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
#endif

[Icons]
Name: "{group}\{#appname}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#appname}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppExeName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

;卸载前删除安装目录
[UninstallDelete]
;Type: filesandordirs; Name: "{app}"
Type: filesandordirs; Name: "{app}\temp"
Type: filesandordirs; Name: "{app}\Config"
Type: filesandordirs; Name: "{app}\Log"
Type: filesandordirs; Name: "{app}\Recipe"

;安装前先删除
[InstallDelete]
Type: filesandordirs; Name: "{app}\temp"
Type: filesandordirs; Name: "{app}\unins000.dat"
Type: filesandordirs; Name: "{app}\unins000.exe"

;删除快捷方式
Type: filesandordirs; Name:"{group}\*"

[Registry]
Root: HKLM; Subkey: "Software\MKT\SQL"; ValueType: string; ValueName: name; ValueData: sql; Flags: createvalueifdoesntexist uninsdeletevalue

[Run]
;运行驱动,从临时目录下取文件,不打包到安装目录下
#if IncludeDrive
Filename: {tmp}\mxspinst.exe; WorkingDir: "{tmp}"; Flags: skipifdoesntexist runascurrentuser; StatusMsg: "Installing mxspinst..."
Filename: {tmp}\DI_USB3_WXP_W7_W8_V109.EXE; WorkingDir: "{tmp}"; Flags:  skipifdoesntexist runascurrentuser; StatusMsg: "Installing DI_USB3_WXP_W7_W8_V109..."
Filename: {tmp}\RENESAS-USB3-Host-Driver-30200-setup.exe; WorkingDir: "{tmp}"; Flags:  skipifdoesntexist runascurrentuser; StatusMsg: "Installing RENESAS-USB3-Host-Driver..."
Filename: {tmp}\SW_CAMWAREWIN64_316.exe; WorkingDir: "{tmp}"; Flags:  skipifdoesntexist runascurrentuser; StatusMsg: "Installing SW_CAMWAREWIN64_316..."
#endif
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#appname}}"; Flags: nowait postinstall unchecked skipifsilent runascurrentuser

[INI]
;Filename: "{app}\lan\setup.ini"; Section: "set"; Key: "lan"; String: "{code:MyLangName|{app}}"; Flags: uninsdeletesection

[Code]
//默认选择同意(安装的协议)
procedure InitializeWizard();
begin
WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
end;

// 判断注册表

function InitializeSetup():Boolean;
var
KeynotExist:boolean;
msg:String;

begin
KeynotExist := true;

if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\MKT\SQL', 'name') then
begin
KeynotExist := false;
msg := ‘已安装过,不用再安装’;
MsgBox(msg,mbConfirmation, MB_OK);
end;
Result := KeynotExist
end;

// 根据选择的语言加载相应的配置文件
function MyLangName(Param : String): String;
begin
Result := ActiveLanguage();
end;

// 安装时判断客户端是否正在运行
function InitializeSetup(): Boolean;
var IsRunning: Integer;
begin
Result :=true; //安装程序继续
IsRunning:=FindWindowByWindowName('{#AppWindowName}');
if IsRunning <> 0 then
begin
Msgbox('{#RunningNotice}', mbConfirmation, MB_OK);
Result :=false; //安装程序退出
end;
end;

// 卸载时判断客户端是否正在运行
function InitializeUninstall(): Boolean;
var IsRunning: Integer;
begin
Result :=true; //安装程序继续
IsRunning:=FindWindowByWindowName('{#AppWindowName}');
if IsRunning <> 0 then
begin
Msgbox('{#RunningNotice}', mbConfirmation, MB_OK);
Result :=false; //安装程序退出
end;
end;

 

 

原文地址:https://blog.csdn.net/chengfei112233/article/details/7276279
标签: inno, 安装包, 程序打包

非特殊说明,本博所有文章均为博主原创,

部分转载有可能忘记标注,如侵犯了您的权益,您可以留言我增加原文出处或删除文档。