title: InnoSetup - Check if visual studio 2010 crt redist is installed, if not then run installer
body: <p>I currently have this in this part of Inno script</p>
  
  <pre><code>[Run]
  Filename: {app}\bin\vcredist_x86.exe; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}\bin; StatusMsg: Installing Visual Studio 2010 C++ CRT Libraries...
  </code></pre>
  
  <p>It will run vcredist installer during app installation. But the problem with this is that if the user has it already installed it throws things like</p>
  
  <ul>
  <li>Repair/Remove</li>
  <li>Already newer version detected </li>
  </ul>
  
  <p>Is there any way to avoid this and only run this installer if needed? What should i add to Inno script?</p>
  
  <p>EDIT:</p>
  
  <p>With the help of @John links i made it witht he following function added</p>
  
  <p>I also used <a href="http://blogs.msdn.com/b/astebner/archive/2010/05/05/10008146.aspx" rel="nofollow">this site</a> for refference to get visual studio 2010 crt++ product code and used Uninstall folder in registry to detect if its installed.</p>
  
  <pre><code>function InitializeSetup(): Boolean;
  var
    ErrorCode: Integer;
    RedistInstalled : Boolean;
    Result1 : Boolean;
  begin
    RedistInstalled := RegKeyExists(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{196BB40D-1578-3D01-B289-BEFC77A11A1E}');
    if RedistInstalled then
    begin
      Result := true;
    end else
    begin
      RedistInstalled := RegKeyExists(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{196BB40D-1578-3D01-B289-BEFC77A11A1E}');
      if RedistInstalled then
      begin
        Result := true;
      end else
      begin
        Result1 := MsgBox('This setup requires Microsoft Visual C++ 2010 Redistributable Package (x86). Please install Visual C++ 2010 Redistributable Package (x86) and run this setup again.  '#13#10' '#13#10'Do you want to download Microsoft Visual C++ 2010 Redistributable Package (x86) now?',
          mbConfirmation, MB_YESNO) = idYes;
        if Result1 =false then
        begin
          Result:=false;
        end else
        begin
          Result:=false;
          ShellExec('open',
            'http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe',
            '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
        end;
      end;
    end;
  end;
  </code></pre>
  
  <p>It would still be nice if however installer would continue after downloading/installing or that i could somehow adapt my previous code that runs included(with setup) installer:</p>
  
  <pre><code> [Run]
      Filename: {app}\bin\vcredist_x86.exe; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}\bin; StatusMsg: Installing Visual Studio 2010 C++ CRT Libraries...
  </code></pre>
  
  <p>but this is still good enough.</p>