App with admin rights on InnoSetup

Hi all, after some trouble with InnoSetup I begin to fall in love with this tool… :slight_smile: it is really handy!

However, I face the following problem: I have an app that writes data in its own app folder (eg. ./myapp/somefile.txt). The app is provided for download, so the well-known “security measurements” apply. App and installer are signed.

On macOS, this seems to be not an issue, even if the app resides within the application folder. I tried downloading my own app, installing it, starting - works.

On Windows, downloading and installing the app works. Launching not. It says that the app cannot be executed and fails. Anyway, as soon as I run the app as an administrator, anything is working as intended.

Now I read about giving admin rights to the app on execution automatically which involves a registry entry:

[quote]You can add Registry entry in [Registry] Section that will set to run as Administrator as default action for runnint this app. e.g. Root: “HKLM”; Subkey: “SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers”; ValueType: String; ValueName: “{app}\tomcat7w.exe”; ValueData: “RUNASADMIN”; Flags: uninsdeletekeyifempty uninsdeletevalue; MinVersion: 0,6.1
[/quote]

Guess tomcat7w.exe needs to be replaced with the app name… but I just fairly understand this code.

(I took this from here: http://stackoverflow.com/questions/16978917/how-to-set-run-as-administrator-on-a-file-using-inno-setup )

I wonder if there is an easier method? Maybe some kind of built-in feature of InnoSetup?

Another method I worked out is to change the InnoSetup script to choose a different software installation path:

[Setup]
;…
DefaultDirName={sd}\MyAppName

This suggests the user to install the app directly on the harddrive’s root folder. Well, not the most elegant solution but the app can later write its files without gaining admin privileges.

I’m looking forward any thoughts or help. :slight_smile:
Thank you! :slight_smile:

This is generally a really bad idea and not recommended on macOS or Windows. If it works now there’s no guarantee that it will continue to work in future OS releases. This is what SpecialFolder.ApplicationSupport is for.

Dont try & write files next to the application as this can / will fail in various ways

  • lack of privileges (which you’ve already run into)
  • application being sandboxed on macOS
  • people running the app from a server where they have NO write privileges
    etc

Right. The reason it usually works on macOS is that many users who are the only user in the system are the admin user. Then once you get to a machine where there are more than one or in an Active Directory situation, the users are just regular users without /Applications write permissions.