Inno setup and Windows Universal Runtime

I added the below code to the Inno script for creating an installer:

[Files]
Source: “VC_redist.x86.exe”; DestDir: {tmp}
[Run]
Filename: {tmp}\VC_redist.x86.exe; Parameters: “/install /quiet /norestart”; StatusMsg:
“Installing 32-bit runtime…”; Flags: waituntilterminated

This works fine but ALWAYS install the VC_redist.x86.exe
Is there a way improve the Inno script so it checks if the system already has the necessary runtime and only install it when needed?

I believe the redist itself will exit pretty quickly if it has been installed/restarted once on the machine. You probably don’t need extra logic.

No, it doesn’t. And i do not know why. But the following made my installers work smooth again:

[code][Run]
Filename: “vc_redist.x86.exe”; StatusMsg: “Installing Microsoft Visual C++ Redistributable on x86 …”; Check: not IsWin64 and not VCinstalled
Filename: “vc_redist.x64.exe”; StatusMsg: “Installing Microsoft Visual C++ Redistributable on x64…”; Check: IsWin64 and not VCinstalled

(Code) // This has been changed for the Forum Display. Use [ and ] in InnoSetup please.
function VCinstalled: Boolean;
// Returns True if Microsoft Visual C++ Redistributable is installed, otherwise False.
// The programmer may set the year of redistributable to find; see below.
var
names: TArrayOfString;
i: Integer;
dName, key, year: String;
begin
// Year of redistributable to find; leave null to find installation for any year.
year := ‘’;
Result := False;
key := ‘Software\Microsoft\Windows\CurrentVersion\Uninstall’;
// Get an array of all of the uninstall subkey names.
if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, key, names) then
// Uninstall subkey names were found.
begin
i := 0
while ((i < GetArrayLength(names)) and (Result = False)) do
// The loop will end as soon as one instance of a Visual C++ redistributable is found.
begin
// For each uninstall subkey, look for a DisplayName value.
// If not found, then the subkey name will be used instead.
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, key + ‘\’ + names[i], ‘DisplayName’, dName) then
dName := names[i];
// See if the value contains both of the strings below.
Result := (Pos(Trim('Visual C++ ’ + year),dName) * Pos(‘Redistributable’,dName) <> 0)
i := i + 1;
end;
end;[/code]

Found on StackOverflow: http://stackoverflow.com/questions/11137424/how-to-make-vcredist-x86-reinstall-only-if-not-yet-installed#11172939

Perhaps the built-in quick exit only works on Windows 8.1/10. That’s a handy detection script.

@ Sascha
Doesn’t work here. Where did you put the vc_redist.x64.exe file?

In the [Files] Section as:

Source: "AddOns\\VC_redist.x86.exe"; DestDir: "{tmp}" Source: "AddOns\\VC_redist.x64.exe"; DestDir: "{tmp}"; Flags: 64bit

Still no luck, it still always updates the VC_redist.x86.exe

Did you check StackOverflow? I use this solution on Windows 7 32Bit and it works just fine. I have no clue what’s going wrong.

Did you see and follow the

code // This has been changed for the Forum Display. Use [ and ] in InnoSetup please.[/code]?

Hello @Christoph De Vocht

If you are using the InnoSetup Code for a 32Bit App on 64Bit Windows Machines, please change the following line

Filename: "vc_redist.x86.exe"; StatusMsg: "Installing Microsoft Visual C++ Redistributable on x86 ...."; Check: not IsWin64 and not VCinstalled

to

Filename: "vc_redist.x86.exe"; StatusMsg: "Installing Microsoft Visual C++ Redistributable on x86 ...."; Check: not VCinstalled

otherwise the 32Bit Libs won’t be installed on 64Bit machines.

For my last app, this looked so intimidating that I simply gave up and went for an older version of Xojo.

But this time I want to have HiDPI support, so I better swallow the pill.

My app will be 32 bit, but I want it to install on Windows 64 bit as well as 32 bit Windows.

What is the redistribuable that must be installed ? only x86 ?

[quote=279845:@Michel Bujardet]My app will be 32 bit, but I want it to install on Windows 64 bit as well as 32 bit Windows.

What is the redistribuable that must be installed ? only x86 ?[/quote]

Yes, it is based on your app build, not the OS type a user might run on. So a 32-bit Windows app would use the 32-bit redist or include the 32-bit DLLs.

Super. Thank you Travis.