Reputation: 1
My app exe file looses it's admin rights after inno tool installation.
I implemented a python based app, which requires windows admin privileges when it is running. If I create my app bundle and configure the exe file with admin privilege (right click exe
> properties
> compatibility
> change settings for all users
> run this program as administrator
). Everything works fine, so if I execute the exe, it is started with admin rights.
But if I configure the exe with admin rights (as I mentioned above) and generate a setup.exe via Inno Tool, the exe file looses its admin configuration after installation. So the app exe has always normal user privileges after execution. The check "run this program as administrator" is gone. Sure, the users can set "run this program as administrator" configuration manually, but it is really unprofessional.
Does anyone know where I am making mistake or it is there any other method to do that?
Note:
Relevant Code part:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
PrivilegesRequired=admin
[Registry]
Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\Windows
NT\CurrentVersion\AppCompatFlags\Layers"; ValueType: String;
ValueName: "{app}\{#MyAppExeName}"; \
ValueData: "~RUNASADMIN"; Flags: uninsdeletekey noerror
Upvotes: 0
Views: 531
Reputation: 1
I could solve my problem with magical nutika python compilar tool. --windows-uac-admin parameter provides admin rights for app. Thanks Kay :)
1-install nuitka for python:https://pypi.org/project/Nuitka/
2-execute nuitka command to create the a standalone app with --windows-uac-admin parameter:
py -m nuitka --run --standalone --disable-console --enable-plugin=pyside6 --windows-icon-from-ico=icons\app_icon.png --windows-uac-admin appname.py
3- Your app will ask for admin privilages, when it is executed
Upvotes: 0
Reputation: 202642
The compatibility parameters are not stored into the .exe file (note that the .exe does not change, when you set the parameters). The parameters are stored to Windows registry and are specific to the specific .exe path. If you move the .exe elsewhere (let only to another machine), the parameters do not apply anymore.
See https://superuser.com/q/1248078/213663
The compatibility parameters are intended for legacy applications that are not maintained anymore. Not for new applications.
Your Inno Setup script actually seems to try to set the compatibility registry keys (although you do not mention that in your question). But you write to HKLM
, what you cannot do, if the installer does not have Administrator privileges (there again your script and the question do not agree, as the script seems to require Administrator privileges, but your question claims that it does not). Anyway, you might have 32-bit/64-bit problem. This is covered in Set "RUNASADMIN" application compatibility flag in Inno Setup.
If an application needs Administrator privileges, it should ask for them on its own (via application manifest or programmatically):
How to make my program ask for administrator privileges on execution
Moreover make sure that your application has legitimate reason to require Administrator privileges. And not lame reasons as described here:
Application does not work when installed with Inno Setup
Upvotes: 2