How to add administrator privileges to the folder after installation

94 views
Skip to first unread message

Li Mr

unread,
Dec 8, 2022, 3:32:56 AM12/8/22
to innosetup
Hello, I want to know how to make the entire installation folder have administrator rights after the program is installed
The software version I use is 6.2.1 and the following efforts have been made
[Setup]
Privileges Required=admin
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "Run now "{#MyAppName}""; Flags: nowait postinstall skipifsilent runascurrentuser

But currently it seems that only the installer itself uses administrator privileges by default, I don't know how to make the whole folder after installation have administrator privileges

Gavin Lambert

unread,
Dec 8, 2022, 6:06:01 PM12/8/22
to inno...@googlegroups.com
On 8/12/2022 21:32, 'Li Mr' wrote:
> Hello, I want to know how to make the entire installation folder have
> administrator rights after the program is installed

If you really need to do that, then you need to give your program a
"requireAdministrator" manifest resource when you compile it. It might
be a setting in your compiler project.

However, for >90% of applications, you shouldn't do that -- this should
be treated as a bug in your code instead.

Applications installed per-machine (such that admin rights are required
to install) should not be attempting to write anything to their own
folder, as this is both a security hole and causes problems with
clashing data when multiple users attempt to run the app.

It is possible to grant write permissions at install time, but this is
still the wrong solution for most cases (and should be limited to
specific subfolders that do not contain executable files, if you must).


Either switch to per-user deployment (which limits your dependencies) or
(better) fix your app so that it stores runtime data in the per-user
paths instead.

https://learn.microsoft.com/en-nz/archive/blogs/patricka/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions

Reply all
Reply to author
Forward
0 new messages