Inno Setup 5打包exe遇到的坑,做一个学习记录

; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "人员管理系统"
#define MyAppVersion "1.0"
#define MyAppPublisher "谷多软件"
#define MyAppURL "http://www.goldou.com/"
#define MyAppExeName "Goldou.UserBase.exe"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{5FAE5728-06AB-401F-AD4D-34D8979DA96A}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=D:Program FilesMicrosoft Goldou User
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=setup
SetupIconFile=E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugResourceslogo.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; OnlyBelowVersion: 0,8.1
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone

[Files]
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.UserBase.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugAspose.Cells.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugAspose.Words.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugAxInterop.EloamThumbnailLib.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugAxInterop.EloamViewLib.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.BLL.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.BLL.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.Common.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.Common.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.DAL.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.DAL.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.DBHelper.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.DBHelper.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.Model.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.Model.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.UserBase.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.UserBase.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.UserBase.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.UserBase.vshost.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.UserBase.vshost.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugGoldou.UserBase.vshost.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebuggoldou_salary.db"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugHandyControl.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugHandyControl.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugHandyControl.xml"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugInterop.EloamThumbnailLib.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugInterop.EloamViewLib.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebuglibzkfpcsharp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugMicrosoft.Windows.Shell.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugOpenSmtp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugorg.in2bits.MyXls.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugSystem.Data.SQLite.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugToastNotifications.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugToastNotifications.Messages.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project环境shoping_clientGoldou.prsion_shoppingGoldou.prsion_shoppinginRelease - 副本dotNetFx40_Full_x86_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugscanFile*"; DestDir: "{app}scanFile"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "E:Project2020507人员管理系统Goldou_fire_Hoody_aotoscanGoldou.UserBaseinDebugResources*"; DestDir: "{app}Resources"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion,注意文件夹输出”

[Icons]
Name: "{group}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"
Name: "{group}{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}MicrosoftInternet ExplorerQuick Launch{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Code]
function InitializeSetup: Boolean;
var
Path,tmppath:string ;
ResultCode: Integer;
dotNetV2RegPath:string;
dotNetV2DownUrl:string;
dotNetV2PackFile:string;
begin
dotNetV2RegPath:='SOFTWAREMicrosoft.NETFrameworkPolicyv4.0';
dotNetV2DownUrl:='http://dl1sw.baidu.com/soft/9b/15910/Microsoft.NET.exe?version=585709662';
dotNetV2PackFile:='{src}dotNetFx40_Full_x86_x64.exe';


//先在注册表查找.net4.0是否存在
if RegKeyExists(HKLM, dotNetV2RegPath) then
begin
Result := true;
end

//如果注册表里面没有发现.net4.0
else
begin
if MsgBox('系统检测到您没有安装.Net Framework4.0运行环境,是否立即安装?', mbConfirmation, MB_YESNO) = idYes then
begin
//和setup同级目录下的donet安装包
Path := ExpandConstant(dotNetV2PackFile);
//先抽取到临时目录
tmppath := ExpandConstant('{tmp}dotNetFx40_Full_x86_x64.exe');
ExtractTemporaryFile('dotNetFx40_Full_x86_x64.exe');

msgbox(tmppath, mbConfirmation, MB_YESNO);
Exec(tmppath, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);


if(FileOrDirExists(tmppath)) then
begin
Exec(tmppath, '/q', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
if RegKeyExists(HKLM, dotNetV2RegPath) then
begin
Result := true;
end
else
begin
MsgBox('未能成功安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
end
end
else
begin
if MsgBox('软件安装目录中没有包含.Net Framework4.0的安装程序,是否立即下载后安装?', mbConfirmation, MB_YESNO) = idYes then
begin
Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
Exec(Path, dotNetV2DownUrl , '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
MsgBox('请安装好.Net Framework4.0环境后,再运行本安装包程序!',mbInformation,MB_OK);
Result := false;
end
else
begin
MsgBox('不下载安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
Result := false;
end
end
end
else
begin
MsgBox('没有安装.Net Framework2.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
Result := false;
end;

end;

end;

原文地址:https://www.cnblogs.com/wx18638101223/p/13784697.html