Install external file from subdirectory (relative path) using Inno Setup - installation

I would like to install an external file.
My installer is located in
c:\somedir\setup.exe
And the external file is located in
c:\somedir\download\MyApp.exe
My code to do that is
[Files]
Source:"\download\MyApp.exe"; DestDir: "{app}";Flags: external skipifsourcedoesntexist
For some reason, Inno Setup does not seem to find this file.
Can anybody tell me what I'm doing wrong?
Thank you.

You have two problems:
The path \download\MyApp.exe relative to c:\somedir\ resolves to c:\download\MyApp.exe, as the leading \ goes back to the root folder. You would need to use download\MyApp.exe.
The Inno Setup does not resolve external file paths relatively to the installer anyway. You have to use a full path, see the documentation for the Source parameter:
When the flag external is specified, Source must be the full pathname of an existing file (or wildcard) on the distribution media or the user's system (e.g. "{src}\license.ini").
You can use the {src} constant to get a full path to the installer folder.
[Files]
Source: "{src}\download\MyApp.exe"; DestDir: "{app}"; \
Flags: external skipifsourcedoesntexist

Use the {src} constant:
[Files]
Source:"{src}\download\MyApp.exe"; DestDir: "{app}";Flags: external skipifsourcedoesntexist

Related

Is it possible to uninstall files based on a condition during uninstall in Inno Setup?

To understand how I use the software:
When starting the installer, the user can choose whether to install or update the software. If he installs the software with the install option, then the software can also be uninstalled regularly via the uninstaller.
I now also misuse the installation function as an update function. Here let's distinguish between the normal upgrade function of Inno Setup and my created update option via code. The update option is nothing more than a normal installation. However, the user must specify any paths to the pre-installed software beforehand. This has to do with the fact that most of our users have already installed the software manually before. (Java, Tomcat and our web application).
The normal installation and my specially created update option work fine so far.
By means of registry entries set during installation or update, I can distinguish whether the software has been installed or updated using the "Installer" or "Updater" option.
If the user has now installed the software via the normal installation option, then it should be possible to uninstall it completely. This means that the (Inno Setup) Uninstaller should delete all files. However, this should not be the case if the user uses the update option. The update function works by backing up some files before the regular installation, deleting unnecessary files using DelTree, and then letting the installation recreate them.
Is it possible to set a condition so that the uninstaller does not delete these files in the Files section if the user has previously used the Update option?
Normally, of course, the uninstaller should delete these files if the user has previously installed the software using the install option. However, I would like these files not to be deleted if the user has previously selected the update option in the installer.
The following is a brief portion of my options:
[Setup]
UninstallFilesDir={code:UnInstallerPath}
[Files]
Source: "<source>\Tomcat9\*"; DestDir: "{code:GetTomcatSourcepath}"; Excludes: "webapps"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\{#JAVA}\*"; DestDir: "{code:GetJAVAExtractpath}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\Tomcat9\webapps\ROOT\*"; DestDir: "{code:GetWebAppSourcepath}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\config\*"; DestDir: "{code:GetConfigInstallPath}"; Check: IsInstaller; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\libraries\{#DLLFile}"; DestDir: "{code:GetConfigInstallPath}"; Flags: ignoreversion
[UninstallDelete]
Type: filesandordirs; Name: "{code:GetUninstallPath}"; Check: IsInstalledviaProgram;
Type: filesandordirs; Name: "{code:UnInstallerPath}";
So the uninstaller should not delete any files other than its own exe and the associated data file if the installer was only used for the update using my created update function.
Due to the fact that I want to be able to uninstall the application if it was previously installed by the installation option, I unfortunately cannot use the uninsneveruninstall flag.
For better understanding, you can see in the following picture the first page that is displayed after starting the installer.
All Check functions (including those in the UninstallDelete section are evaluated on install time. Not on uninstall time.
Based on the name of your IsInstalledviaProgram function, I guess that it is implemented in a way to work in the uninstaller (by checking the registry entries?). But it is actually executed during the installation. So you should check for the radio buttons, not the registry entries (whose state at the time the function is called likely do not correspond yet). Maybe the IsInstaller is the function you should use.

Inno installer: How to use hi-res desktop icon?

I have a couple of questions about Inno.
One is that I have a hi-res good-looking desktop icon that I made 256x256. But when Inno installs it, a low-res one appears on the desktop.
(The one appearing in the start menu looks Ok and hi-res).
Edit: this became a question to do with the exported format of the .ICO file (an icon file exported from Photoshop was not exporting correctly - see answers below), as well as a caching problem which was alleviated with a reboot.
(Sometimes, when I make an icon change in Inno, its not reflected on the computer I just tested the install on. Its only when I go to another computer and install it, do I see the new changes. Is there a cache or something that I have to clear to see new changes?)
#define MyAppExeName "navdraw.exe"
#define MyAppIcoName "C:\kivymd\Inno\IGPDesktopIcon.ico"
[Setup]
SetupIconFile="C:\kivymd\Inno\IGPInstallerIcon.ico"
[Files]
Source: "C:\kivymd\exe\dist\navdraw\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\kivymd\Inno\IGPDesktopIcon.ico"; DestDir: "{app}"; Flags: ignoreversion
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "C:\kivymd\Inno\IGPDesktopIcon.ico"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "C:\kivymd\Inno\IGPDesktopIcon.ico"; Tasks: desktopicon
I do not know why even the low res icon appears, as your script is wrong.
The IconFilename parameter must point to a file on the target machine. So like this:
IconFilename: {app}\IGPDesktopIcon.ico
That also explains your "caching problem".

How can I reproduce symbolic link in Inno Setup on the target machine?

I include a symbolic link from the source machine into Inno Setup. When running the installer on the target machine, it deploys a copy of the source file in place of the symbolic link. How do I make the installer preserve the symbolic links?
[Files]
Source: "c:\source path*"; Excludes:"*.log"; DestDir: "C:\destination path"; \
Flags: ignoreversion recursesubdirs createallsubdirs
You cannot "install" a symbolic link using the Files section. Inno Setup does not support symlinks.
You have to create the link explicitly on the target machine. For that, see How can I create a symbolic link with Inno Setup?
To avoid installing the symlinked file twice, you may need to exclude it from the installation using the Excludes parameter.

Expand an x86 .exe to 'C:\Windows\System32' under both Windows x86 and x64?

I would like to make my installer compatible under both x86/x64 windows, this means portable.
I did the innosetup installer only to expand an x86 CLI executable file, and I need to expand it to C:\windows\system32 directory even if the installer is running under a Windows x64 because otherwise if I expand it to C:\Windows\Syswow64 directory then the exe is not recognized under a Windows x64 CMD.
So how I should set this property to make it portable with the specified condition above?:
ArchitecturesInstallIn64BitMode= ???
And what flags I should use when expanding the file here?:
Source: {sys}\My_x86_application.exe; DestDir: {sys}; Flags: ???
I've played a little bit with some flags like 32Bit, 64Bit, and Is64BitInstallMode, but I can't get the expected result because if I know that restricted constants as {syswow64} throws an installation error under a Windows x86...
UPDATE
This is the relevant part of my installation script, but it is wrong, it should be compatible with x86 and x64 windows (portable) and only expand the Source: {sys}\* files to C:\Windows\System32 under both windows (using the constant {sys} to detect the dir path, of course).
[Setup]
DefaultDirName={pf32}\{#AppName}
ArchitecturesAllowed=x86 x64
ArchitecturesInstallIn64BitMode=x64
[Files]
Source: {app}\*; DestDir: {app}; Flags: ignoreversion
Source: {sys}\*; DestDir: {sys}; Flags: ignoreversion 64bit
Answered in parts like your question:
ArchitecturesInstallIn64BitMode
Valid values: One or more of the following, separated by spaces:
x64
ia64
Default value: (blank)
Description: Specifies the 64-bit processor architecture(s) on which Setup should install in 64-bit mode. If this directive is not specified or is blank, Setup will always install in 32-bit mode. Normally, you should not change this directive from its default value unless your application contains native 64-bit binaries.
You have a x86 exe binary so leave the field blank.
Source (Required)
Description: The name of the source file. The compiler will prepend the path of your installation's source directory if you do not specify a fully qualified pathname.
Example:
Source: "My_x86_application.EXE"
Leaving it without any path like the entry above might be optimal (for small projects, because it messes the files to be deployed with the setup script). Also, beware that Constants may only be used when the external flag is specified, because the compiler does not do any constant translating itself. So, the following entry:
Source: {sys}\My_x86_application.exe; DestDir: {sys}
actually expects to have the binary stored in the {sys} subfolder of a directory with the setup script. If that would not be so, the compilation fails.
DestDir (Required)
I think you can specify System32 always using {win}\System32. Since both x86 and x64 version of Windows contain the System32 directory.
For the Flags and further doubt clarification visit this page.
EDIT: Save the iss file in the same folder where your x86 exe binary exists. Then Run it.

How can I install a driver using Inno Setup?

I'd like to install a driver for a serial port using Inno Setup. I have the inf file, and I can install the driver manually through device manager, but I'd like to be able to include the driver in my installer so that users don't have to go through the trouble of installing the driver themselves.
See InstallHinfSection in Microsoft documentation. The documentation also mentions how to invoke an installation by calling Rundll32.exe. Probably you'll end up with something like this:
[Files]
..
Source: "driver\my_x86driver.inf"; DestDir: {app}\driver;
Source: "driver\my_x86driver.sys"; DestDir: {app}\driver;
[Run]
..
Filename: {sys}\rundll32.exe; \
Parameters: "setupapi,InstallHinfSection DefaultInstall 128 {app}\driver\my_x86driver.inf"; \
WorkingDir: {app}\driver; Flags: 32bit;
Note that you might need to run the setup in 64bit mode in 64bit systems to be able to install the driver:
[Setup]
..
ArchitecturesInstallIn64BitMode=x64
Also you can put checks as to run the version of .inf file depending on machine architecture (e.g. Check: Is64BitInstallMode).
I used dpinst like this:
[Files]
Source: "Source\dpinst\dpinst32.exe"; DestDir: "{app}\driver"; DestName: dpinst.exe; Check: not IsWin64; Flags: ignoreversion
Source: "Source\dpinst\dpinst64.exe"; DestDir: "{app}\driver"; DestName: dpinst.exe; Check: IsWin64; Flags: ignoreversion
[Run]
Filename: "{app}\driver\dpinst.exe"; Parameters: "/A /LM";
This is a better answer: Install drivers with rundll32 or dpinst in Inno Setup?
Using InstallHinfSection on Windows 7 and beyond seems to be either broken or fraught with difficulty. Making it work from a batch file is difficult, making it work from Inno Setup is even more difficult. dpinst seems preferable, and is simpler.

Resources