title: Inno Setup launch executable (to install drivers) during installation
body: <p>I am using Inno Setup to create an installer for my application. The installer is very basic and just copies some files. This works very well and I am happy with it.</p>
  
  <p>I recently implemented USB support and need to install the USB driver from the IVI foundation for that. It is basically an exe file that has to be launched somewhere during the setup process. Until now, the user has to install the drivers separately, which is not so elegant. My first approach was this:</p>
  
  <pre><code>[Run]
  Filename: "{app}\driver\IviSharedComponents_2.2.1.exe"; Description: "Install USB driver (IVI Foundation)"; Flags: postinstall skipifsilent
  Filename: "{app}\driver\IviSharedComponents64_2.2.1.exe"; Description: "Install 64bit USB driver (IVI Foundation)"; Flags: postinstall skipifsilent
  Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&amp;", "&amp;&amp;")}}"; Flags: postinstall skipifsilent
  </code></pre>
  
  <p>This works, but the user has to select the correct bitness. The advantage here is that he can choose not to install it (in which case the application just ignores the USB functionality which is fine). What I actually want is to detect the bitness of the system automatically and run the setup process. This does not have to be in the <code>[Run]</code> section, although I would not have anything against it (because the user can choose not to install it).</p>
  
  <p>I also found some code and tried to run it like this:</p>
  
  <pre><code>[Code]
  procedure CurStepChanged (CurStep: TSetupStep);
  var
     WorkingDir:   String;
     ReturnCode:   Integer;
  begin    
     if (ssInstall = CurStep) then
       Log('Starting driver installation');
       WorkingDir := ExpandConstant ('{app}\driver');
       Exec ('IviSharedComponents_2.2.1.exe', '', WorkingDir, SW_SHOW, ewWaitUntilTerminated, ReturnCode);
  end;
  </code></pre>
  
  <p>But this does not start the installation (although I can see the log entry 'Starting driver installation'). Is there something wrong with my path? What am I doing wrong and how could I change this script to automatically select the right executable depending on the bitness?</p>
  
  <p>EDIT: I used the proposed solution with the <code>[Tasks]</code> entry. The implementation looks like this (just for reference):</p>
  
  <pre><code>[Tasks]
  Name: "install_usb"; Description: "Install USB drivers (IVI Foundation)"; GroupDescription: "External drivers:";
  
  [Run]
  Filename: "{app}\driver\IviSharedComponents_2.2.1.exe"; StatusMsg: "Installing USB driver (IVI Foundation)"; Check: Not IsWin64(); Tasks: install_usb; Flags: skipifsilent
  Filename: "{app}\driver\IviSharedComponents64_2.2.1.exe"; StatusMsg: "Installing USB driver (IVI Foundation)"; Check: IsWin64(); Tasks: install_usb; Flags: skipifsilent
  </code></pre>
  
  <p>This works very well, thanks a lot for your help!</p>