Custom setup on operating system and architecture - inno-setup

I have been asked to have a setup procedure running in the following operating systems:
Windows Vista (only x86) and higher (both x86 and x64)
In order to restrict whole setup from running in older operating systems I added into [Setup] section the Minversion=0,6.0.6000 that corresponds to Windows Vista.
I wonder if in Pascal scripting it is possible to apply a conditional installation like the following:
[Run]
Filename: "{tmp}\mysetup.exe"; Components: Install; MinVersion: 0,6.0.6000; Check: not Iswin64;
Filename: "{tmp}\mysetup.exe"; Components: Install; MinVersion: 0,6.1.7600;
This way mysetup.exe should run only on Vista x86 and on all higher operating systems.

Use GetWindowsVersion and IsWin64 support functions:
if ((GetWindowsVersion >= $06000000) {Vista} and (not IsWin64)) or
(GetWindowsVersion >= $06010000) {7} then
begin
// Install
end;

I believe what you are looking for is MinVersion
It's one of the optional parameters that are supported on all sections that support parameters.
Documentation can be found here: http://www.jrsoftware.org/ishelp/index.php?topic=commonparams&anchor=MinVersion

Related

Inno Setup - Do not install DirectX when already installed

I'm using this code in [Run] section:
Filename: "{src}\DirectX\DXSETUP.exe"; StatusMsg: "Wait for install DirectX package..."; \
Flags: waituntilterminated skipifsilent skipifdoesntexist
And when I try to reinstall program, every time I get pop-up with DirectX installation. How to prevent reinstalling DirectX, when it's installed already?
See ISXKB for DirectX - How to detect DirectX version article.
It has useful functions, which you can use to detect, if required version of DirectX is already installed on the machine.
Using these functions, you can easily implement a check function:
[Run]
Filename: "{src}\DirectX\DXSETUP.exe";
StatusMsg: "Wait for install DirectX package..."; \
Flags: waituntilterminated skipifsilent skipifdoesntexist; Check: InstallDirectX
[Code]
function InstallDirectX: Boolean;
begin
Result := (CompareVersion(GetDirectXVersion(), '4.8.0') < 0);
end;

Inno Setup - Run programs after ssPostInstall code that processes installed files

I am installing DirectX and vc_2013_x64 from components section (and from Run section) and I am using this code too: How to add .arc decompression to Inno Setup? (answer of Martin Prikryl). How to move the installation of DirectX and vc_2013_x64 (if it is possible) to after the decompressing page (and before the finish page)? (Because with this code the installation is in the middle between installing page and decompressing page).
I am using this script to execute the sub-installers:
[Run]
Filename: {src}\_Redist\dxwebsetup.exe; StatusMsg: Installing DirectX...
Filename: {src}\_Redist\vcredist_x64.exe; StatusMsg: Installing vcredist_x64...
There are many ways, e.g.:
Run the ExtractArc from the AfterInstall parameter of the archive Run entry, instead of the CurStepChanged event function:
Source: {#ArcArchive}; DestDir: "{tmp}"; Flags: nocompression deleteafterinstall; \
AfterInstall: ExtractArc
Or execute the dxwebsetup.exe and vcredist_x64.exe from the CurStepChanged before the ExtractArc, using the Exec function.

How to install .sys file into c:\windows\system32\drivers with Inno Setup? [duplicate]

This question already has an answer here:
File/DLL installed to {sys} does not appear in C:\Windows\system32
(1 answer)
Closed 4 years ago.
I try to simply install a .sys file into
Source: "C:\myproject\driver.sys"; DestDir: "{win}\system32\drivers";
Once the setup ran, my driver.sys is always installed into
C:\Windows\SysWOW64\drivers
Any idea why?
By default the {win}\system32 is redirected to {win}\SysWOW64 by the OS for 32-bit applications (like Inno Setup).
You can override this using 64bit flag:
Source: "C:\myproject\driver.sys"; DestDir: "{win}\system32\drivers"; Flags: 64bit
64bit: Causes the {sys} constant to map to the 64-bit System directory when used in the Source and DestDir parameters, .... This is the default behavior in a 64-bit mode install.
Or enable 64-bit mode install.
[Setup]
ArchitecturesInstallIn64BitMode=x64 ia64
In 64-bit mode:
The System32 path returned by the {sys} constant maps to the 64-bit System directory by default when used in the [Dirs], [Files], [InstallDelete], [Run], [UninstallDelete], and [UninstallRun] sections. This is because Setup/Uninstall temporarily disables WOW64 file system redirection when files/directories are accessed by those sections. Elsewhere, System32 and {sys} map to the 32-bit System directory, as is normal in a 32-bit process.
As mentioned is all the references above, you should better use {sys} constant instead of {win}\system32:
Source: "C:\myproject\driver.sys"; DestDir: "{sys}\drivers"
{sys} The system's System32 directory.
For example: If you used {sys}\CTL3D32.DLL on an entry and the system's Windows System directory is "C:\WINDOWS\SYSTEM", Setup or Uninstall will translate it to "C:\WINDOWS\SYSTEM\CTL3D32.DLL".
On 64-bit Windows, by default, the System32 path returned by this constant maps to the directory containing 32-bit system files, just like on 32-bit Windows. (This can be overridden by enabling 64-bit mode.)

Inno Setup - How to execute MSI between 32 and 64 architectures

im trying to run 2 msi files for 32 and 64 bits from a third party and i am having a little trouble with the msi for 32bits windows architectures.
It seems the program extracts quite well the file but it doesn´t execute the installer. In the other hand for 64bits windows architectures the installer works. I don´t know where is the problem. Is there anything wrong with my code that im not seeing?Thank you!
[Setup]
...
ArchitecturesInstallIn64BitMode=x64
[Files]
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: "filex64.msi"; DestName: "file.msi"; DestDir: "{app}"; Flags: deleteafterinstall; Check: Is64BitInstallMode
Source: "filex32.msi"; DestName: "file.msi"; DestDir: "{app}"; Flags: deleteafterinstall; Check: not Is64BitInstallMode;
Source: "manual.pdf"; DestDir: "{userdesktop}"; DestName: "Manual.pdf"
[Run]
Filename: "{sys}\msiexec.exe"; Parameters: "/package ""{app}\file.msi"" /qn /norestart /passive"; Flags: shellexec waituntilterminated; StatusMsg: "A instalar software {#MyAppVersion}";
Filename: "{userdesktop}\Manual.pdf"; Flags: postinstall;
I figure it out.
Flags
32bit
Causes the {sys} constant to map to the 32-bit System directory when used in the Filename and WorkingDir parameters. This is the default behavior in a 32-bit mode install.
This flag cannot be combined with the shellexec flag.
64bit
Causes the {sys} constant to map to the 64-bit System directory when used in the Filename and WorkingDir parameters. This is the default behavior in a 64-bit mode install.
This flag can only be used when Setup is running on 64-bit Windows, otherwise an error will occur. On an installation supporting both 32- and 64-bit architectures, it is possible to avoid the error by adding a Check: IsWin64 parameter, which will cause the entry to be silently skipped when running on 32-bit Windows.
This flag cannot be combined with the shellexec flag.
Source:
http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_iswin64
Based on this, i changed my script ir order to pinpoint correctly the "msiexec.exe" file for both architectures. Thank you guys!
[Run]
Filename: "{sys}\msiexec.exe"; Parameters: "/package ""{userdesktop}\Classic_Client_{#MyAppVersion}_64.msi"" /qn /norestart /passive"; Flags: 64bit skipifdoesntexist waituntilterminated; Check:IsWin64; StatusMsg: "A instalar Classic Client {#MyAppVersion} - 64bit";
Filename: "{sys}\msiexec.exe"; Parameters: "/package ""{userdesktop}\Classic_Client_{#MyAppVersion}_32.msi"" /qn /norestart /passive"; Flags: 32bit skipifdoesntexist waituntilterminated; StatusMsg: "A instalar Classic Client {#MyAppVersion} - 32bit";
the {sys} constant is the issue.
{sys} The system's System32 directory. For example: If you used
{sys}\CTL3D32.DLL on an entry and the system's Windows System
directory is "C:\WINDOWS\SYSTEM", Setup or Uninstall will translate it
to "C:\WINDOWS\SYSTEM\CTL3D32.DLL".
On 64-bit Windows, by default, the System32 path returned by this
constant maps to the directory containing 32-bit system files, just
like on 32-bit Windows. (This can be overridden by enabling 64-bit
mode.)

how to detect 64bit platform by script

is there code to detect 64 platform e.g.
if X86 then ...
if X64 then ...
If you want to throw a check on whether to drop or run a file you can also throw a check on the call.
Check: IsWin64;
or even
Check: "not IsWin64";
This allows a quick and easy way to compile 32-bit & 64-bit application installers into one package, but only run the specific one.
EDIT: To expand a little further for those that might be searching for this, I wanted to follow up.
For example, if you want to only allow certain files to be copied down by the installer you could do the following:
[Files]
Source: "MyProg-x64.exe"; DestDir: "{app}"; Check: IsWin64;
Source: "MyProg-x86.exe"; DestDir: "{app}"; Check: "not IsWin64";
Adapted from source: http://www.jrsoftware.org/ishelp/index.php?topic=scriptcheck
Yes.
Use
if IsWin64 then
// Do sth
else
// Do sth else
There is also a Is64BitInstallMode function. Indeed, a 32-bit setup can run on a 64-bit OS. Hence, Is64BitInstallMode implies IsWin64, but IsWin64 does not imply Is64BitInstallMode.

Resources