I want to add vcredist_x64.exe and vcredist_x86.exe with my Inno Setup installer. How my installer will detect the OS whether it is 64bit or 32bit and it will install the file vcredist file as per OS.
Asked
Active
Viewed 613 times
1 Answers
1
Try this:
in the [Files] section add
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: IgnoreVersion replacesameversion; Check: "not IsWin64";
Source: "vcredist_x64.exe"; DestDir: {tmp}; Flags: IgnoreVersion replacesameversion; Check:IsWin64;
and in your [Code] section do:
function Launch_VCRedist(svDir:String) : Boolean;
var
svTargetApplication: String;
svParameter: String;
workingDir: String;
showCmd: Integer;
wait: TExecWait;
resultCode: Integer;
VersionMS, VersionLS : Cardinal;
Major, Minor, Rev, Build: Cardinal;
Version:String;
begin
Result := True;
//Optional: if you want to execute silently your redist.exe, add this. This is for vc_redist version from 2005 to 2012
GetVersionNumbers(svDir + '\vcredist_x86.exe', VersionMS, VersionLS);
Major := VersionMS shr 16;
case Major of
11: //2012
begin
svParameter := '/install /passive';
end
10: //2010
begin
svParameter := '/passive /showfinalerror';
end
6: //2005
begin
svParameter := '/q';
end
9: //2008
begin
svParameter := '/Q';
end
end;
workingDir := '';
showCmd := SW_SHOW;
wait := ewWaitUntilTerminated;
retVal := Exec(svDir + '\vcredist_x86.exe', svParameter, workingDir, showCmd, wait, resultCode)
if retVal then
begin
//handle success if necessary; resultCode contains the exit code
end
else begin
//handle failure if necessary; resultCode contains the error code
Result := False;
end;
end;
And in CurStepChanged procedure add:
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssPostInstall:
b_ret := Launch_VCRedist(ExpandConstant('{tmp}'));
if b_ret Then
begin
//Handle success if necessary
end
else begin
//Handle failure if necessary
end;
end;
end;

Sandburg
- 757
- 15
- 28

KingOfMazes
- 130
- 1
- 12
-
Thanks for your reply. In which section I will place below code block (And in CurStepChanged procedure add:). Please reply. – user3606222 Dec 26 '15 at 05:49
-
@user3606222 Those functions can be placed everywhere in the [Code] section. If you already have a CurStepChanged function inside your code section, add the b_ret := Launch_VCRedist(ExpandConstant('{tmp}')); like the example – KingOfMazes Jan 07 '16 at 13:30
-
Is that a typo? `Check: Check:IsWin64;` – Sandburg Nov 21 '18 at 16:51