【问题标题】:Check System Architecture in Inno Setup在 Inno Setup 中检查系统架构
【发布时间】:2015-09-30 11:50:14
【问题描述】:

我正在使用Inno Setup 为我的.NET 开发的项目创建一个BootStrapper。

在使用PascalScript 时,我遇到了一些问题。但在此之前,这是我用来创建BootStrapper的脚本

#define MyAppName "<ProductName>"
#define MyAppVersion "<ProductVersion>"
#define MyAppPublisher "<Company Name>"
#define MyAppURL "<URL>"
#define MyAppExeName "<AppName>.exe"
#define MyAppCopyright "Copyright@2015"
#define MyContact "<Contact No>"

[Setup]
AppId={{69A884D3-671F-4DFB-9E23-F6FA35BD6264}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=<License File Path>
OutputDir=<Output Directory Path>
OutputBaseFilename=<Output File Name>
Compression=lzma
SolidCompression=yes
SetupIconFile=<Icon File Path>
ArchitecturesInstallIn64BitMode=x64
AppCopyright={#MyAppCopyright}
AppContact={#MyContact}
VersionInfoVersion=1.5
VersionInfoCompany=<Company Name>
VersionInfoProductName=<Product Name>
VersionInfoProductVersion=<Product Version>

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

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

[Files]
Source: "<Path>\NDP452-KB2901907-x86-x64-AllOS-ENU.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall; Permissions: admins-full; Check: Framework45IsNotInstalled
Source: "<Path>\CRRuntime_32bit_13_0_13.msi"; DestDir: "{tmp}"; Flags: deleteafterinstall 32bit; Permissions: admins-full;
Source: "<Path>\CRRuntime_64bit_13_0_14.msi"; DestDir: "{tmp}"; Flags: 64bit deleteafterinstall; Permissions: admins-full; Check: IsWin64
Source: "<Path>\SSCERuntime_x86-ENU.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall 32bit; Permissions: admins-full
Source: "<Path>\SSCERuntime_x64-ENU.exe"; DestDir: "{tmp}"; Flags: 64bit deleteafterinstall; Permissions: admins-full; Check: IsWin64

Source: "<Path>\<Product>.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "<Path>\File1.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Run]
Filename: {tmp}\NDP452-KB2901907-x86-x64-AllOS-ENU.exe; Parameters: "/q /norestart"; Check: Framework45IsNotInstalled; StatusMsg: Microsoft Framework 4.0 is being installed. This process might take some time. Please wait.....

Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\CRRuntime_32bit_13_0_13.msi"; StatusMsg: Crystal Reports Runtime is being installed. Please wait....;

Filename: {tmp}\SSCERuntime_x86-ENU.exe; StatusMsg: Microsoft SQL Compact 4.0 is being installed. Please wait.....

[Code]
function Framework45IsNotInstalled(): Boolean;
var
  regresult: Cardinal;
begin
  RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Install', regresult);
  if (regresult = 0) then 
  begin
    Result := True;
  end
  else
  begin
  Result := False;
  end;
end;

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
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

现在我有关于这个问题的三个问题:

  1. 如何判断系统架构是32Bit还是64Bit,并相应执行相应的文件?

例如如脚本中所述,我为Crystal Reports 附加了两个文件,现在在执行安装程序时,安装程​​序应该检测系统架构并运行相应的文件。我尝试使用This Link here on StackOverdlow 解决这个问题,但不太明白。

  1. 检查系统上是否已安装先决条件

例如为了检查机器上是否已经安装了.NET Framework,我得到了上面提到的脚本并且它工作正常。 Crystal ReportSQL Compact 如何做到这一点?

我为Crystal Report 尝试了这个脚本,但它不起作用。

[Code]
function CheckForCrystalReports: Boolean;
var
  regresul: Cardinal;
begin
  RegQueryDWordValue(HKLM, 'SOFTWARE\SAP BusinessObjects\Suite XI 4.0\Installer\CRV','Install',regresul);
  if(regresul = 0) then
  begin
  Result := True;
  end 
  else
  begin
  Result := False;
  end; 
end;
  1. 在静默模式下运行可执行文件

例如在上面的脚本中,我使用Parameters: "/q /norestart"; 在静默模式下运行设置及其工作。但是如何为 *.msi 文件做到这一点?我尝试了一些参数,但它们不起作用。

【问题讨论】:

  • 你不能在一篇文章中提出三个不同的问题。
  • 反正第一个问题,见Inno-setup 32bit and 64bit in one
  • @MartinPrikryl:很抱歉提出大问题,感谢您提供链接。它奏效了。
  • @RobeN:感谢您的链接。我已经尝试过了,但参数/q/qn 不起作用。执行时提示错误信息为Parameters not supported

标签: crystal-reports inno-setup pascalscript


【解决方案1】:

ShellExec试试这个解决方案:

[Run] 
Filename: "{tmp}\CRRuntime_32bit_13_0_13.msi"; Parameters: "/passive";
 Flags: shellexec waituntilterminated skipifdoesntexist;
 StatusMsg: "Crystal Reports Runtime is being installed. Please wait..."; 

如果您想通过MSIEXEC拨打电话:

[Run] 
Filename: "msiexec.exe"; Parameters: "/passive /i ""{tmp}\CRRuntime_32bit_13_0_13.msi"""; 
 Flags: waituntilterminated skipifdoesntexist; 
 StatusMsg: "Crystal Reports Runtime is being installed. Please wait...";

附注在来自 Comment 的代码 sn-p 中,Parameters 缺少引号。您应该使用" 打开和关闭参数,然后如果您需要在参数行中使用引号,则必须将其加倍。 ""


对于SQL Compact,您可以使用以下代码:

[Files]
Source: "C:\Temp\SSCERuntime_x64-ENU.exe"; DestDir: "{tmp}"; 
 Flags: nocompression deleteafterinstall uninsremovereadonly  
Source: "C:\Temp\SSCERuntime_x86-ENU.exe"; DestDir: "{tmp}"; 
 Flags: nocompression deleteafterinstall uninsremovereadonly  

[Run] 
Filename: "{tmp}\SSCERuntime_x64-ENU.exe"; Parameters: "/qn /i";  
 Flags: waituntilterminated skipifdoesntexist; 
 StatusMsg: SQL Compact 4.0 x64 is being installed. Please wait...; 
 Check: (IsWin64) and (not IsSQLCompact40Installed); 
Filename: "{tmp}\SSCERuntime_x86-ENU.exe"; Parameters: "/qn /i";  
 Flags: waituntilterminated skipifdoesntexist; 
 StatusMsg: SQL Compact 4.0 x86 is being installed. Please wait...; 
 Check: (not IsWin64) and (not IsSQLCompact40Installed); 

[Code]
function IsSQLCompact40Installed(): Boolean;
var
  InstallDirString : String;
begin
  result := false;
  if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v4.0',
   'InstallDir', InstallDirString) then begin
    if FileExists(InstallDirString + '\sqlcecompact40.dll') then
       result := true;
  end;
end;

【讨论】:

  • 谢谢。它就像一个魅力。你能帮我解决我提到的其他问题吗?
  • 我还有一个问题 2 未决。 :)
  • 导出并附加HKLM \SOFTWARE\SAP BusinessObjects 的注册表分支。您还必须指定要检查的 SQL Compact 版本 - 3.5、4.0? x86、x64?
  • @Mahadev 我已经通过 SQL Compact 的示例检查更新了答案
  • @RobenN :非常感谢,但我已经为 SQL Compact 解决了这个问题。但是谢谢你IsSQLCompact40Installed()。如果可能的话,请让我知道水晶报告的任何类似注册表项。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-22
相关资源
最近更新 更多