cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DMorisseau
Level 5

Detecting if RunAsAdmin w/InstallScript

I have an InstallScript project that is serving as the entry point for a series of installs to install our project suite. Is there a way that I can detect if the setup has been launched in "Run As Administrator" on Vista or later OSes.
Labels (1)
0 Kudos
(3) Replies
cslims
Level 2

I needed to check for this as well but also have another question. The solution that I found was to check for USER_ADMINISTRATOR as in:

if ! (Is(USER_ADMINISTRATOR, "")) then
MessageBox("You must use the 'Run as administrator' option to install this product", SEVERE);

else
.
.
endif;

HTH. My question is once you've detected that run as admin was not used, how do you raise an error to prevent other custom actions from executing? My objective is to check for run as admin as early as possible and if False then end the installation.

Thanks.
Cesar
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

Typically I would suggest changing the Required Execution Level setting on the releases view to Require Administrator. If you need to take cslims's approach, usually the abort; statement will help you exit the setup without modifying the system.
0 Kudos
cslims
Level 2

Thanks for the abort tip Michael, I'll try that. I do have Require Administrator set however due to how AD policies are handled here, the tech does not have local admin permissions on the workstation so simply Require Admin does not do the trick.

Cesar
0 Kudos