title: Inno Setup drivers install
body: <p>I cannot find a way for Inno Setup to install drivers.</p>
  
  <p>I have checked these questions here:
  <a href="https://stackoverflow.com/questions/8864549/inno-setup-install-drivers-with-rundll32-or-dpinst">Inno setup: install drivers with rundll32 or dpinst?</a>
  <a href="https://stackoverflow.com/questions/3493416/how-to-run-a-file-before-setup-with-inno-setup">How to run a file before setup with Inno Setup</a> and <a href="https://stackoverflow.com/questions/8723836/how-to-install-directx-redistributable-from-inno-setup">How to install DirectX redistributable from Inno-setup?</a>.</p>
  
  <p>My code is like this:</p>
  
  <pre><code>[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;
  </code></pre>
  
  <p>1) Right now my installer crashes because it cannot find drivers\dpinst64.exe when extracting the temporary file.</p>
  
  <p>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.</p>
  
  <p>What could be the problem here? Is there another better way to initiate driver instalation right before the installer finishes its work?</p>