3

我需要一些帮助来制作 Inno Installer,我想在我自己的项目的同时安装驱动程序。当驱动程序只是一个“exe”文件时,它可以正常工作:

[Files]
Source: ".\Component\Drivers\Driver1\driver1.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode;
[Codes]
ExtractTemporaryFile('driver1.exe');
Exec(ExpandConstant('{tmp}\driver1.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

但是,当驱动程序具有更复杂的依赖关系时,情况就不一样了。我试图将所有文件放在临时目录中(是的,这很丑=))并执行驱动程序,但这个解决方案不起作用。

[Files]
Source: ".\Component\Drivers\Keithley Driver\*"; DestDir: "{tmp}"; Check: Is64BitInstallMode;

[Code]
ExtractTemporaryFile('setup.exe');
Exec(ExpandConstant('{tmp}\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

你对我有什么好的建议吗?我可以将驱动程序及其所有依赖项压缩到一个“exe”文件中吗?感谢您的帮助,最好的问候,克莱门特。

更新 2: 这是我的整个代码:

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

#define MyAppName "App"
#define MyAppVersion "1.0"
#define MyAppPublisher "Other"
#define MyAppURL "http://www.other.fr"
#define MyAppExeName "App.exe"

[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.)
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
VersionInfoVersion={#MyAppVersion} 
AllowNoIcons=yes
OutputDir=.\Deployment
OutputBaseFilename=App-Setup
SetupIconFile=.\Component\App.ico
Compression=lzma
SolidCompression=yes
WizardImageFile=.\Component\App.bmp
WizardSmallImageFile=.\Component\App.bmp

[Languages]
Name: "en"; 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: ".\Component\Cal\*"; DestDir: "{app}\Cal"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Documentation\*"; DestDir: "{app}\Documentation"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Softwares\Utility\*"; DestDir: "{app}\Utility"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Softwares\System32\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\Component\Softwares\App\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: ".\Component\Drivers\Keithley Driver\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: "{tmp}";
Source: ".\Component\Drivers\Spec Driver\driver.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode;
Source: ".\Component\Drivers\Adaptater\adaptater.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode;

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
I: Integer;
begin
  // CurStep values
  // ssInstall, ssPostInstall, ssDone
  MsgBox('Hello.', mbInformation, MB_OK);
  if CurStep = ssPostInstall then begin
    Exec(ExpandConstant('{tmp}\Keithley Driver\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
    Exec(ExpandConstant('{tmp}\driver.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

    // Ask the user a Yes/No question
    if MsgBox('Do you need to use the Adaptater?', mbConfirmation, MB_YESNO) = IDYES then
    begin
      Exec(ExpandConstant('{tmp}\adaptater.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
      MsgBox('Please, plug it now!', mbInformation, MB_OK);
      for I := 0 to 10 do
      begin
        Sleep(400);
      end;
    end;
  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

更新 3: 这是我安装具有依赖项的驱动程序的最后 [代码] 部分:

[Files]
Source: ".\Component\Drivers\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: "{tmp}";

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
I: Integer;
begin
  // CurStep values
  // ssInstall, ssPostInstall, ssDone
  if CurStep = ssPostInstall then begin
    Exec(ExpandConstant('{tmp}\Keithley Driver\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
    Exec(ExpandConstant('{tmp}\Driver\driver.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

    // Ask the user a Yes/No question
    if MsgBox('Do you need to use the Adaptater?', mbConfirmation, MB_YESNO) = IDYES then
    begin
      Exec(ExpandConstant('{tmp}\Adaptater\adaptater.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
      MsgBox('Please, plug it now!', mbInformation, MB_OK);
      for I := 0 to 10 do
      begin
        Sleep(400);
      end;
    end;
  end;
end;

非常感谢瑞克!

4

1 回答 1

2

ExtractTemporaryFile('setup.exe');如果目的地已经是 {tmp},我不知道你为什么要打电话。

我认为这已经足够了(注意源和中的通配符deleteafterinstall):

[Files]
Source: ".\Component\Drivers\Keithley Driver\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: {tmp}

[Code]
Exec(ExpandConstant('{tmp}\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

ExtractTemporaryFile()我以为只有在源代码行中有dontcopy-flag 时才会使用。然后该文件将不会被提取,您可以在代码中手动完成。没有dontcopy-flag 你不需要它。

您的[code]细分也不完整。

这是一个工作.iss的小例子:

[Setup]
AppName=test
AppVerName=test
DefaultDirName=C:\TEMP
OutputBaseFilename=test
OutputDir=C:\TEMP
Uninstallable=no
;PrivilegesRequired=none
PrivilegesRequired=admin
Compression=lzma/ultra
SolidCompression=yes

[Files]
Source: ".\Component\Drivers\Keithley Driver\*"; Flags: deleteafterinstall createallsubdirs recursesubdirs; DestDir: {tmp}

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
begin
  // CurStep values
  // ssInstall, ssPostInstall, ssDone
  if CurStep = ssPostInstall then begin
    MsgBox('Hello.', mbInformation, MB_OK);
    Exec(ExpandConstant('{tmp}\setup.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  end;
end;

您的文件只会在 ssPostInstall 阶段的 {tmp} 目录中(而不是在 ssInstall 阶段)。

于 2013-09-20T13:25:51.843 回答