Search code examples
registrysetup-projectaccess-rights

How to make an executable running as administrator with install forge


I am using install forge (http://installforge.net/) to produce a setup file for my software. However, the soft recquires admin rights to run for some reasons. One easy solution is to ask the user to "right click -> execute as admin" or any of the similar mehtods. But I want to make it automatically without any user interraction on a Windows 8.1 system.

I found some solutions using the registry in How to set "Run this program as an administrator" programmatically but I was unsuccessful when trying it in install forge GUI.


Solution

  • Ok, I found a solution :

    In the InstallForge/System/registry pannel, you have to add a new variable with the following parameters :

    enter image description here

    e.g :

    • Root key = HKEY_CURRENT_USER
    • Sub key : \Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers : This is where you want to add the value, keep this exact path, it is standard.
    • Value : <installpath>\pathToYourExe\program.exe This is the path where your will have your exe installed.
    • Value data : ~ RUNASADMIN (this is specific to windows 8.1 as far as I understood, this value was simply "RUNASADMIN" before that version. (No typo, there is a space between "~" and "RUNASADMIN"

    You can check that the value has been added by looking at the registry using the regedit.exe command.

    Ideally I wanted to add another variable for Root key=HKEY_LOCAL_MACHINE but for some reason the value is not taken into account in the registry when using the same method. However, having only the HKEY_CURRENT_USER is enough for me at the moment.