How do I check if the install mode is admin or not and use that information for adding registry keys at different locations (Inno setup)?

49 views Asked by At

I am an extreme beginner in Inno Setup (Pascal scripting). I am on Windows and using Inno Setup and I am trying to edit a registry value (environment variable PATH) so that the user can start my application from command-line.

I have tried something like:

[Code]
begin
if (IsAdminInstallMode()) then
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}";  
[Code]
else
[Registry]
Root: HKLM; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}";
[Code]
end

This approach doesn't seem to see the isAdminInstallMode() call on line 3, just simply opens a dialog box during installation saying that permissions to write to HKLM\... are not available (when running from non-admin account).

Note: I have included this:

PrivilegesRequiredOverridesAllowed=dialog

i.e., the setup program opens up a dialog asking to install in administrative mode or non-administrative mode.

I know my code is very wrong, as I am a complete beginner. Please can anyone tell me what's wrong? Thanks.

0

There are 0 answers