最近手贱,把以前写的一个完整的INNO打包脚本给删了,于是又得到处找资料学习。现在分享一个完整的脚本代码,以后就不会找不到了。脚本为完整diamante,包括了这些基本的功能:写注册表、检测程序是否正在运行、调用exe、配置生成文件相关属性等。
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "××××"
#define MyAppVersion "2.3.29.15"
#define MyAppPublisher "有限公司"
#define MyAppURL "http://www.******.com/"
#define MyAppExeName "******.exe"
;#define MyProgramsMutexName "C0BD666C-45AB-48D2-AAA8-C535E624134C"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{C0BD666C-45AB-48D2-AAA8-C535E624134C}
;AppMutex={#MyProgramsMutexName}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
VersionInfoProductVersion={#MyAppVersion}
VersionInfoProductTextVersion={#MyAppVersion}
VersionInfoVersion={#MyAppVersion}
VersionInfoCompany={#MyAppPublisher}
VersionInfoCopyright={#MyAppPublisher}{#'版权所有'}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\Jelin\Desktop\InnoOut
OutputBaseFilename=MySetup{#MyAppVersion}
SetupIconFile=******\res\*****.ico
Compression=lzma
SolidCompression=yes
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "E:\<span style="font-family: Arial, Helvetica, sans-serif;">******</span><span style="font-family: Arial, Helvetica, sans-serif;">\Release\****.exe"; DestDir: "{app}"; Flags: ignoreversion</span>
Source: "E:\*****\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
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
[UninstallRun]
Filename: "{app}\******.exe"; Parameters: "/uninstall"
;注册表启动项
[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "testrun"; ValueData: "{app}\{#MyAppExeName}"
Root: HKLM; Subkey: "Software\**********"; ValueType: string; ValueName: "version"; ValueData: "{#MyAppVersion}"
Root: HKLM; Subkey: "Software\<span style="font-family: Arial, Helvetica, sans-serif;">**********</span><span style="font-family: Arial, Helvetica, sans-serif;">"; ValueType: string; ValueName: "path"; ValueData: "{app}"</span>
;安装时判断客户端是否正在运行
[Code]
function InitializeSetup(): Boolean;
var
IsRunning: Integer;
begin
Result :=true; //安装程序继续
IsRunning:=FindWindowByClassName('UIMainFrame'); ;检查程序是否正在运行
while IsRunning<>0 do
begin
if Msgbox('安装程序检测到********正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
begin
Result :=false; //安装程序退出
IsRunning :=0;
end else begin
Result :=true; //安装程序继续
IsRunning:=FindWindowByClassName('UIMainFrame');
end;
end;
end;
function InitializeUninstall(): boolean;
var
IsRunning: Integer;
begin
Result:= true;
IsRunning:= FindWindowByClassName('UIMainFrame');
begin
if IsRunning<>0 then
begin
MsgBox('******正在运行,请先关闭它!', mbConfirmation, MB_OK);
Result:= false;
end
else
begin
Result:= true
end;
end;
end;