How to access the path of Inno Setup installed program from OUTSIDE of Inno Setup? - inno-setup

According to the docs, Inno Setup uses AppName or AppId to allow you to create an update program that will automatically put its files in the same path which the user installed the initial application to.
I need to be able to determine where Inno Setup installed files to based on AppId, but NOT from within Inno Setup. For example, I need to be able to determine this from a Python script.
One use case: patching a file in the installed program location. It would be overkill to package an entire installer just to, say, conditionally add or edit a line in a text file. A simple Python script could accomplish this, plus the user could review the script if they desired. I cannot and should not assume the user just installed to the default location, hence why I need to be able to see where the user installed the program.
Inno Setup obviously stores this somewhere since it is able to make its own patches, but I can't seem to find it in the registry. I've searched the Registry for my app ID but I only see it in the Uninstall section. I can probably pull it from there, but I think you can also create installers without uninstallers – where would this end up in that case?

The path is stored to registry to HKLM (administrative install mode) or HKCU (non administrative install mode) to a subkey named after the AppId with _is1 suffix, stored under a key SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (as you alraedy know). The value name is Inno Setup: App Path. The path is also stored to InstallLocation with additional trailing slash, as that's where Windows reads it from. But Inno Setup reads the first value.
An example for HKLM:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\appid_is1]
"Inno Setup: App Path"="C:\\Program Files\\My Program"
"InstallLocation"="C:\\Program Files\\My Program\\"
You can see this in dozens questions, that show how to read the value in Inno Setup code. For example:
How to get path of installation of target game/application from registry when installing mod/plugin using Inno Setup?
If you create an installer what cannot be uninstalled (CreateUninstallRegKey=no or CreateUninstallRegKey=no), then the path is not store anywhere. In such case you would have to explicitly code your installer to store the path for you somewhere.

Related

Make installer capable of installing addon files to various applications in Inno Setup

I have a set of files (scenery data of an airport) that should be installed to one of several applications (3 different flight simulators) depending on the target applications being installed. If more than one is installed, the user has to choose into what application the set of files should be installed.
Of course I could write for each application a separate installer but that would make it awkward to maintain and blow up the number of installers since there are many sets of files to install.
Problem is that depending on the chosen application the AppId, the installation destination and other installation values changes.
I intend to write a custom wizard page that is shown immediately after the welcome page to find out which of the target applications are installed and let the user choose the required application in case there are several installed.
My current problem is that the files to copy are not fully the same for each possible application. So I need in the [Files] section the posibility to copy a file to its target location depending on the application selected. I hoped to find a general parameter for the [Files] section that could be used to copy or not. But I could not find one. How could I solve this problem? I also studied [Components] and [Tasks] to find a solution but was not successful.
Thanks for any hint how to solve my problem!
To answer your literal question: Use Check parameter to bind [Files] (and other) section entries to the selection on the custom page.
Some examples:
Inno Setup - Multiple software versions in one installation
How to install only file based on condition (external configuration file) in Inno Setup
Conditional file copy in Inno Setup
Inno Setup: How to auto select a component by comparing a register key version?
Though you also might consider using a preprocessor to easily maintain and auto-generate multiple installers from same source script.
For an example, see:
Compile Inno Setup installer for specific component only

Remove read-only attribute from existing files in Inno Setup

I'm creating a setup with Inno Setup. This setup adds files to a "main program" and after installing some files it runs another custom program which kind of unpacks some previously installed files.
This unpacking program relies on some existing files being writable, which usually is the case. But on development machines these files are under version control and therefore write protected (have read-only attribute).
The unpacking program just doesn't unpack when these files are write protected (maybe it shows a warning in the console, but the console is hidden so one won't see this warning). And I can't change the code of this unpacking program.
So, I'm looking for a way to make these files writable with Inno Setup even though these files are not installed by Inno Setup.
How can I achieve this?
There's no built-in mechanism for that in Inno Setup.
But you can do almost anything from Pascal Script using WinAPI. In this case, you want to use SetFileAttributes.
For an example how to use SetFileAttributes from Inno Setup, see:
Inno Setup Code section create hidden file

Where is Inno Setup uninstaller executable?

I'm very new to Inno Setup, so forgive my ignorance on this one.
I created a very small install script and it's building and working the way I want—I get my setup.exe built to the output directory, and all the source files are being copied to my specified destinations.
Now I want to make sure users can uninstall the files that I specified in my [Files] section of my script. The problem is I don't understand how Inno Setup handles this. I assume Inno Setup doesn't make an executable specifically for Uninstall, but even if I run setup.exe after I have installed my application, the wizard doesn't ask if I want to uninstall.
However, if I enable the Run menu's Target Uninstall in the ISC compiler, I am able to uninstall the files. So my question is, how do I uninstall my application outside of the ISC compiler. In my [Setup] section I do have Uninstallable=yes.
I know this is a total noob question, but any help is appreciated.
(As you have found yourself), Inno Setup creates an entry in Add/Remove Programs Control Panel applet (if CreateUninstallRegKey is yes).
The entry is a link to an uninstaller program, which is generated by the compiler (when Uninstallable is yes).
The uninstaller program is located by default in the application directory (unless overridden by UninstallFilesDir) and is named unins001.exe (the number is incremented, if needed, to avoid naming conflicts).

Inno Setup files owned by Administrator

My setup project performs a UAC check because it uses regserver. This is OK (and in fact necessary); however it makes all of the installed files be owned by Administrator , and not by the user that originally ran the installer.
This means that the user that ran the installer cannot edit any of the configuration files that are part of my installation.
I don't want to set permission on the files to be writable by Everyone; they just need to be writable by the user that ran the installation.
Does Inno Setup have any way of assigning ownership of certain files (or all of the files) to the user that ran the self-installing executable?
I am not using the line PrivilegesRequired=admin although it seems makes no difference whether or not that line is active. (Presumably because regserver implies this).

Inno Setup and the Windows UAC shield

I am stuck at some UAC issue (I guess).
My question is: What does this UAC Shield Icon on some applications mean? And how would I get this icon to my Inno Setup setup.exe?
Inno Setup installers require Admin Privileges by default (if not customized by installer creator). UAC popup will be triggered if user did not change UAC settings in Windows.
http://www.jrsoftware.org/ishelp/index.php?topic=setup_privilegesrequired
[Setup]: PrivilegesRequired
Valid values:
none, poweruser, admin, or lowest
Default value:
admin
Description:
The effect of this directive depends on which version of Windows the user is running:
As others have said, Inno Setup requires administrator privileges by default, and will trigger the UAC prompt. You can change that with PrivilegesRequired. The problem with this is that it doesn't show the shield icon on the executable.
The best way to do it is to use the Microsoft's Manifest Tool and change the manifest embedded in the executable. It is usually included in Microsoft SDKs, which are free to download from Microsoft. Once you install it, the Manifest Tool is usually located in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin\mt.exe. Note that some SDKs don't include it. I also found it in https://github.com/eladkarako/mt, if you don't want to install the SDK.
To extract the manifest from the executable, execute this in the command line: "path to mt.exe" -inputresource:"path_filename.exe";#1 -out:"path_filename.exe.manifest"
Now change asInvoker to requireAdministrator in path_filename.exe.manifest (manifest files are actually XMLs, so you can edit them with a text editor)
To put the manifest into the executable: "path to mt.exe" -manifest "path_filename.exe.manifest" -outputresource:"path_filename.exe";1
There you go! The executable now has the shield icon no matter what!
There's another method, which is far less useful. You can change the executable to run as administrator in the registry (same as right clicking it --> Properties --> Compatibility --> checking Run as Administrator on). To do this, create a string value that has the name set as the path+filename of the executable, and contains the data/text RUNASADMIN; the value has to be created in:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers if you want to change it for the current user
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers if you want to change it for all users (this usually requires you to have administrator privileges)
The problem with it is that it doesn't carry over if you move the executable (you have to do it all over again) or give it to someone else (they have to do it, or have to run some tool to do it). This is not useful.

Resources