MultiPar icon indicating copy to clipboard operation
MultiPar copied to clipboard

Installer does not request elevation when installing to protected folder

Open Taomyn opened this issue 3 years ago • 4 comments

Installer does not request elevation when installing to protected folder and so completely fails when installing to somewhere like C:\Program Files (x86)\MultiPar then rolls back install.

v1.3.1.8 beta Windows 10 Pro 21H1 (UAC fully enabled)

Taomyn avatar May 25 '21 06:05 Taomyn

Installer does not request elevation when installing to protected folder

This is a problem of Inno Setup, which cannot elevate privilege dynamically. Then, I wrote a precautionary statement on "ReadMe_English.txt" or "How to install MultiPar". But, new users may not read it.

I post the text here;

To install under "Program Files" or "Program Files (x86)" directory, you must start the installer with administrative privileges by selecting "Run as administrator" on right-click menu.

Yutaka-Sawada avatar May 25 '21 10:05 Yutaka-Sawada

@Yutaka-Sawada - according to Inno Setup Help files, https://jrsoftware.org/ishelp/index.php?topic=setup_privilegesrequired this should be available.

[Setup]: PrivilegesRequired

Valid values: admin, or lowest
Default value: admin
Description:

This directive affects whether elevated rights are requested (via a User Account Control dialog) when the installation is started.

When set to admin (the default), Setup will always run with administrative privileges and in administrative install mode. If Setup was started by an unprivileged user, Windows will ask for the password to an account that has administrative privileges, and Setup will then run under that account.

When set to lowest, Setup will not request to be run with administrative privileges even if it was started by a member of the Administrators group and will always run in non administrative install mode. Do not use this setting unless you are sure your installation will run successfully on unprivileged accounts.

For those who need non admin rights, if you set that setting to admin, there is also the ability to override privileges: https://jrsoftware.org/ishelp/index.php?topic=admininstallmode

Non Administrative Install Mode

An installation can run in one of two modes: administrative or non administrative. Which mode is selected is specified by the PrivilegesRequired and PrivilegesRequiredOverridesAllowed [Setup] section directives.

In administrative install mode:

The {group} folder is created in the All Users profile.
The "auto" form of the directory and Shell Folder constants is mapped to the "common" form.
The "user" form of these constants should NOT be used: user-level files and settings must be handled by the application itself, and never in an administrative install mode installer.
The HKA, uninstall info, and font install root keys will be HKEY_LOCAL_MACHINE.

In non administrative install mode:

The {group} folder is created in the current user's profile.
The "auto" form of the directory and Shell Folder constants is mapped to the "user" form.
The HKA, uninstall info, and font install root keys will be HKEY_CURRENT_USER.
Notes:

Regardless of the version of Windows, if the installation is running in administrative install mode then you should be careful about making any per-user area changes: user-level files and settings must be handled by the application itself, and never in an administrative install mode installer. The compiler will warn you about this, which can be disabled using UsedUserAreasWarning.

If the installation is running in non administrative install mode, but administrative privileges are available anyway then Setup or the [Code] section might still make use of these privileges. For this reason the uninstaller will always be marked as requiring administrative privileges in this case, just as if the installation was running in administrative install mod.

From the main Inno Setup help pages, it seems that these may be version specific (currently at version 6.2).

I've also used other programs that use Inno setup perfectly fine to install to Program Files also.

JohnLGalt avatar Jun 16 '21 17:06 JohnLGalt

Inno Setup supports both Administrative or Non Administrative Install Modes. It switches the mode at opening time. It cannot change the mode depending on the installing folder. This is the problem, which I complain.

For example, it should request admin privilege, only when installing in Program Files directory. It won't need admin privilege for installing in other folders.

I've also used other programs that use Inno setup perfectly fine to install to Program Files also.

It's because you have admin privilege of your PC. It must run under Administrative Install Mode (with admin privilege), and opens UAC dialog at first. If you don't have admin privilege, you cannot open Inno Setup. Even when you want to install in a normal folder, UAC refuse to start the installer. I found the defect on a PC with limited user account in a library.

Yutaka-Sawada avatar Jun 17 '21 00:06 Yutaka-Sawada

Ahh, yes, now I see - it won't proactively change based upon installation location. And since I use MP in portable mode I did not notice this.

JohnLGalt avatar Jun 18 '21 14:06 JohnLGalt