项目inno setup安装脚本,带检测.net framework
来源:互联网 发布:博士德汽修软件 编辑:程序博客网 时间:2024/06/03 05:39
几乎完全不懂pascal脚本,只是看过这种安装脚本,搞了三天才搞好,各种测试,各种改,终于做出了一个比较完整的安装包。
要说,还是有很多改进的地方,比如没有使用procedure,inno setup可以依照勾选项进行不同的安装步骤,安装完之后可以也可以进行相应的操作,可定制各种安装方式,
以下是我的安装脚本:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "appname"
#define MyAppNameEn "appname english"
#define MyAppVersion "2.0.0.0"
#define MyAppPublisher "publisher name, Inc."
#define MyAppExeName "eTMS.exe"
#define MyAppLoggingName "系统登陆"
#define MyAppLoggedName "windows logged name"
#define RegGridPPBatName "注册控件.bat"
#define RegGridPPName "注册控件"
#define DebugSourcePath "..\Main\bin\x86\Debug"
#define ReleaseSourcePath "..\Main\bin\x86\Release"
[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={{A6A7578-84EC-4006-8226-C87D71FB94}
AppName=" {#MyAppName} [{#MyAppVersion}] "
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\{#MyAppNameEn}
DefaultGroupName=物流云平台
DisableProgramGroupPage=yes
LicenseFile=..\Doc\agreement_chs.txt
InfoBeforeFile=..\Doc\agreement_chs.txt
InfoAfterFile=..\Doc\Readme.txt
OutputDir=..\setup
OutputBaseFilename="{#MyAppName}{#MyAppVersion}"
Compression=lzma
SolidCompression=yes
[Languages]
; 默认安装包打包出来是英文版,并且没有中文视图,需要自己添加
Name: "Chinese"; MessagesFile: "compiler:Languages/Chinese.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
[Files]
Source: "..\Doc\agreement_chs.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Doc\agreement_chs.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Doc\Readme.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ReleaseSourcePath}\eTMS.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ReleaseSourcePath}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\Dependency\other\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\Dependency\reggridpp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\Dependency\szb\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{commondesktop}\升级程序"; Filename: "{app}\UpgraderClient.exe"; Tasks: desktopicon
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\升级程序"; Filename: "{app}\UpgraderClient.exe"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
Filename: "{app}\{#RegGridPPBatName}"; Description: "{cm:LaunchProgram,{#StringChange(RegGridPPName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Messages]
BeveledLabel={#MyAppPublisher}
ConfirmUninstall="您真的想要从电脑中卸载{#MyAppName}吗?%n%n按【是】则完全删除 %1 以及它的所有组件;%n按 【否】则让软件继续留在您的电脑上. "
[Registry]
Root: HKLM ;SubKey:"Software\{#MyAppName}";ValueType:dword;ValueName:config;ValueData:10 ;Flags:uninsdeletevalue
;在执行脚本
[code]
//全局变量
var
ErrorCode,IsRunning: Integer;
const WM_CLOSE=$0010;
// 程序是否运行或在登录中
function GetLogedOrLoggingWindow() : Integer;
begin
result:=FindWindowByWindowName('{#MyAppLoggedName}');
if(result = 0) then
begin
result:=FindWindowByWindowName('{#MyAppLoggingName}');
end;
end;
// 检测.net framework 4.0安装环境,并安装.net框架
function CheckDotNetFrameWork() : Boolean;
var
ResultCode: Integer;
Path, dotNetV4RegPath, dotNetV4PackFile, wic : string;
begin
dotNetV4RegPath:='SOFTWARE\Microsoft\.NETFramework\policy\v4.0';
dotNetV4PackFile:='{src}\环境配置\dotNetFx40_Full_x86_x64.exe';
wic:='{src}\环境配置\wic_x86_chs.exe';
if RegKeyExists(HKLM, dotNetV4RegPath) then begin
Result := true;
end
else begin
// Exec(ExpandConstant(wic), '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); // 安装wic,windows xp系统会需要安装wic
if MsgBox('正在安装客户端必备组件.Net Framework 4.0,可能会花费几分钟,请稍后……', mbConfirmation, MB_YESNO) = idYes then begin
Path := ExpandConstant(dotNetV4PackFile);
if(FileOrDirExists(Path)) then begin
Exec(Path, '/norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
Result := true;
end
else begin
if MsgBox('软件安装目录中没有.Net Framework的安装程序,' #13#13 '单击【是】跳过.Net Framework 4.0安装,【否】将退出安装!', mbConfirmation, MB_YESNO) = idYes then begin
Result := true;
end
else begin
// path := expandconstant('{pf}\internet explorer\iexplore.exe'); //从官网下载
// exec(path, 'http://www.microsoft.com/en-us/download/confirmation.aspx?id=17851', '', sw_shownormal, ewwaituntilterminated, resultcode);
// msgbox('请安装好.net framework4.0环境后,再运行本安装包程序!',mbinformation,mb_ok);
Result := false;
end;
end;
end
else begin
Result := false;
end;
end;
end;
// 卸载之前的安装版本
function UnInstallBefore() : Integer;
var ResultCode : Integer;
UnInstallFile : String;
begin
ResultCode:=-1;
UnInstallFile:=''
RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{A6A7578-84EC-4006-8226-C87D71FB94}_is1', 'UninstallString', UnInstallFile);
StringChangeEx(UnInstallFile, '"', '', True);
if(FileExists(UnInstallFile)) then begin
Exec(UnInstallFile, '/norestart', ExtractFilePath(UnInstallFile), SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
end;
Result :=ResultCode;
end;
//判断程序是否存在
//初始华程序事件
function InitializeSetup() : Boolean;
begin
Result :=true; //安装程序继续
IsRunning:=GetLogedOrLoggingWindow()
while IsRunning<>0 do
begin
if Msgbox('系统检测到客户端正在运行,请确认是否关闭?' #13#13 '单击【是】自动关闭客户端并继续安装,【否】退出安装!', mbConfirmation, MB_YESNO) = idNO then begin
Result :=false; //安装程序退出
IsRunning :=0;
exit;
end
else begin
SendMessage(IsRunning,WM_CLOSE,0,0); // 关闭进程
Result :=true; // 安装程序继续
IsRunning:=GetLogedOrLoggingWindow()
end;
end;
// 检查是否已经安装过应用程序
if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\{#MyAppName}', 'config') then begin
if Msgbox('客户端已安装过,是否卸载重装?' #13#13 '单击【是】卸载并重装,【否】退出安装!', mbConfirmation, MB_YESNO) = idYES then begin
UnInstallBefore();
Result :=true; //安装程序继续
end
else begin
Result :=false; //安装程序退出
IsRunning :=0;
end
end
else begin
Result :=CheckDotNetFrameWork(); //安装程序继续
IsRunning:=GetLogedOrLoggingWindow();
end;
end;
// 卸载时判断客户端是否正在运行
function InitializeUninstall() : Boolean;
begin
Result :=true; //安装程序继续
IsRunning:=GetLogedOrLoggingWindow();
while IsRunning<>0 do
begin
if Msgbox('系统检测到客户端正在运行,请确认是否关闭?' #13#13 '单击【是】自动关闭客户端并继续卸载,【否】退出!', mbConfirmation, MB_YESNO) = idNO then begin
Result :=false; //安装程序退出
IsRunning :=0;
end
else begin
SendMessage(IsRunning,WM_CLOSE,0,0);
Result :=true; //安装程序继续
IsRunning:=GetLogedOrLoggingWindow();
end;
end;
end;
参照文档:
http://blog.csdn.net/ahao1985507/article/details/39182977 安装包中的code部分参照
http://blog.csdn.net/goodadult2012/article/details/6442035 自动检测.net framework
http://www.cnblogs.com/liancs/archive/2012/09/14/2685061.html 安装视图汉化方法
- 项目inno setup安装脚本,带检测.net framework
- 我想用inno setup检测用户电脑是否安装了.net framework
- Inno setup安装脚本
- inno 程序安装脚本,检测.net framework 环境并提供.net 2.0sp2下载链接
- inno setup 提前安装外围程序,比如.net framework
- Inno Setup 简单安装脚本
- inno setup 安装 .net 服务
- Inno setup 打包。net framework 2.0
- Inno Setup:Checking .NET Framework versions
- 使用Inno Setup 打包.NET程序,并自动安装.Net Framework
- 使用Inno Setup 打包.NET程序,并自动安装.Net Framework
- Inno Setup 安装脚本的初级应用
- Inno Setup 安装Borland产品脚本
- Inno Setup一个打包安装脚本示范.
- Inno Setup一个打包安装脚本示范.
- Inno Setup 5.22安装脚本示例
- Inno Setup唯一打包安装脚本示范
- 比较完整的Inno Setup 安装脚本
- AAC音频格式分析
- 微服务架构的基础框架选择:Spring Cloud还是Dubbo?
- iOS多线程GCD
- 关于结构体的思考
- 似然函数Likelihood Function
- 项目inno setup安装脚本,带检测.net framework
- @SpringBootApplication的使用
- MapReduce\Tez\Storm\Spark四个框架的异同
- 2.Mac 环境下配置apache-maven
- group by 多个条件
- 怎么查看APK的方法数
- IT--linux--centos使用shadowsocks
- Qt 中使用C++11标准
- 1019. General Palindromic Number (20)