Inno Setup drivers install

driverinno-setupinstallation

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?

Best Answer

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;