4

I cannot find a way for Inno Setup to install drivers.

I have checked these questions here: Inno setup: install drivers with rundll32 or dpinst? How to run a file before setup with Inno Setup and How to install DirectX redistributable from Inno-setup?.

My code is like this:

[Files]
Source: "drivers\dpinst64.exe"; DestDir: "{app}\drivers"; Check: Is64BitInstallMode; Components: drivers;

[code] 
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ResultCode: Integer;
begin

  if IsWin64 then begin
      ExtractTemporaryFile('drivers\dpinst64.exe');
      Exec(ExpandConstant('{tmp}\dpinst64.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  end;    

end;

1) Right now my installer crashes because it cannot find drivers\dpinst64.exe when extracting the temporary file.

2) Before this i tried simply running the .exe in [run] but nothing happened. When the .exe was run, the run lasted 5 miliseconds and then I got the -2147483648 return code. Exec(ExpandConstant('{win}\notepad.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) runs just fine in InitializeSetup.

What could be the problem here? Is there another better way to initiate driver instalation right before the installer finishes its work?

Community
  • 1
  • 1
Paul
  • 193
  • 1
  • 11

3 Answers3

2

If you try this, what will happen?

What is the parameter to install dpinst64.exe? From your attempt, it looks like this (assuming that {tmp} ends up being Windows %TEMP%):

%TEMP%\dpinst64.exe -install "%TEMP%"

Is it the correct statement to install dpinst64.exe?

[Files]
Source: "drivers\dpinst64.exe"; DestDir: "{tmp}"; Check: Is64BitInstallMode; Components: drivers;

[Code] 
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ResultCode: Integer;
begin

  if IsWin64 then begin
      ExtractTemporaryFile('dpinst64.exe');
      Exec(ExpandConstant('{tmp}\dpinst64.exe'), '-install "' + ExpandConstant('{tmp}') + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  end;    

end;

I assume that the driver dpinst64.exe is the only file in the drivers folder of your source that needs to be distributed in your installer. If it is not the case, then you should type as follows:

[Files]
Source: "drivers\*"; DestDir: "{tmp}"; Check: Is64BitInstallMode; Components: drivers;
ecle
  • 3,952
  • 1
  • 18
  • 22
  • I forgot that the driver exe also needs several files and libraries with it, you're right. Bun now i should use something like: Source "drivers\amd64\*"; DestDir: "{tmp}\amd64"; Components: drivers – Paul Feb 13 '12 at 15:39
  • @Paul Good enough, at least you get the idea now :) – ecle Feb 13 '12 at 15:44
0

keep in mind that dpinst is software first meaning it doesn't actually install the device until it is plugged in.

conterio
  • 1,087
  • 2
  • 12
  • 25
0

To answer your questions: 1. You should use ExtractTemporaryFile('dpinst64.exe'); instead of ExtractTemporaryFile('drivers\dpinst64.exe');. 2. For the failure to run the DPINST64.EXE, you might need to extract the INF, SYS, and any other dependencies for the driver into the directory where DPINST64.EXE. You would need multiple ExtractTemporaryFile statements to extract multiple files.

mirtheil
  • 8,952
  • 1
  • 30
  • 29
  • Are subfolders in the {tmp} folder alowed at install time? – Paul Feb 13 '12 at 15:42
  • @Paul Yes, you can create subfolders under `{tmp}` because `{tmp}` ends up being %TEMP% folder under Windows. If you look into %TEMP%, it has so many subfolders created by so many installers... Hence, you can create `{tmp}\mydrivers` to create a subfolder named `mydrivers` under `{tmp}` folder – ecle Feb 13 '12 at 16:06
  • I have tried [Dirs] Name: "{tmp}\drivers"; and [Files] Source: "drivers\*"; DestDir: "{tmp}\drivers"; Components: drivers; However, when the files are extracted, they are all extracted on the same level, ignoring the initial hierarchy of the drivers folder, which is not useful at all. If i omit the extraction, there are absolutely no files in the {tmp} folder - my guess is that it's a different {tmp} folder in the two stages of the installation. Is there any way to maintain the initial folder structure even after the extraction to tmp? – Paul Feb 13 '12 at 16:25
  • Finally I used this: `[Files] Source: "drivers\*"; DestDir: "{tmp}\drivers"; Components: drivers; Source: "drivers\i386\*"; DestDir: "{tmp}\drivers\i386"; Components: drivers; Source: "drivers\amd64\*"; DestDir: "{tmp}\drivers\amd64"; Components: drivers;` and then simply `[Run] Filename: {tmp}\drivers\dpinst64.exe; WorkingDir: {tmp}\drivers; Flags: skipifdoesntexist;` – Paul Feb 13 '12 at 16:53
  • @Paul Ahh at last, a simple run is just enough :) – ecle Feb 13 '12 at 22:40