title: Inno Setup - How to Install Windows Update Offline Installer
body: <p>I'm writing a function that will install a required component for my appliance, which is built upon PowerShell.  If a specific version of PowerShell is not found, I want the installer to help the user install it.  The problem I'm running into is how to appropriately call the offline installer for installation.  Here is the code I have, which is a generic function (I am using the <a href="http://www.codeproject.com/Articles/20868/NET-Framework-1-1-2-0-3-5-Installer-for-InnoSetup" rel="nofollow noreferrer">InnoSetup Dependency Installer</a>):</p>
  
  
  
  <pre class="lang-pascal prettyprint-override"><code>function SmartExec(product : TProduct; var resultcode : Integer): boolean;
  begin
      if (LowerCase(Copy(product.File, Length(product.File) - 2, 3)) = 'exe') then begin
          Result := Exec(product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
      end else begin
          Result := ShellExec('', product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
      end;
  end;
  </code></pre>
  
  <p>I have tried using the following:</p>
  
  <pre class="lang-pascal prettyprint-override"><code>function SmartExec(product : TProduct; var resultcode : Integer): boolean;
  begin
      if (LowerCase(Copy(product.File, Length(product.File) - 2, 3)) = 'exe') then begin
          Result := Exec(product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
    end else if (LowerCase(Copy(product.File, Length(product.File) - 2, 3)) = 'msu') then begin
          Result := ShellExec('', 'wusa.exe ' + product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
      end else begin
          Result := ShellExec('', product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
      end;
  end;
  </code></pre>
  
  <p>When I compile and test the installer, I'm greeted with:</p>
  
  <p><a href="https://i.stack.imgur.com/KM9QC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KM9QC.png" alt="enter image description here"></a> </p>
  
  <p>I am passing <code>/quiet /norestart</code> as parameters to the MSU file, which execute perfectly from a command prompt.</p>
  
  <p>The installation file is downloaded to <code>%tmp%</code> for the current user, and I see the file.</p>
  
  <p>Any help or comments?</p>