Summary
This article provides sample Java code demonstrating how to programmatically determine whether the current user running the installation is either an administrator on Windows or root on Unix / LinuxSynopsis
This article provides sample Java code demonstrating how to programmatically determine whether the current user running the installation is either an administrator on Windows or root on Unix / Linux. The sample Java code implements a Java class as a Custom Code Rule in InstallAnywhere.
Discussion
The Java code first sets a boolean variable to false as a default value and then gets a handle on the SecurityService through a ruleProxy object. Next, the Java code calls the isCurrentUserAdmin() method, which detects whether the current user is an administrator on Windows or root on Unix / Linux. Finally, the Java code returns the boolean result from the call to the isCurrentUserAdmin() method. If the current user is an Administrator on Windows or root on Unix, the Java code returns true. Otherwise, it returns false.
Compile the source code using the Java compiler and ensure that the IAClasses.zip file (in the InstallAnywhere home directory) and all the JAR files in the <InstallAnywhereHome>\resource\services directory are in the classpath. Place the compiler output (a Java class file) in a JAR file using the Java jar command. Add an Evaluate Custom Rule Action to your project that points to that JAR file and the respective Java class. If you would like the evaluation of the rule to take place before the Pre-Install Task, add the Evaluate Custom Rule Action under Project > Rules > Installer Rules by clicking the Add Rule button.
NOTE: In addition, check the "Add service support for custom code" checkbox found under Project > Java for InstallAnywhere versions from InstallAnywhere 2009 up to InstallAnywhere 2012 with SP1. With the redesign of the UI, this checkbox is under the Project View > JVM Settings View > General Settings Tab for InstallAnywhere 2013 and later. Checking this checkbox ensures that the InstallShield MultiPlatform API services are built into the installer and made available at runtime.
Code:
import com.installshield.wizard.service.security.SecurityService;
import com.zerog.ia.api.pub.*;
public class IsCurrentUserAdmin extends CustomCodeRule
{
public boolean evaluateRule()
public boolean evaluateRule()
{
boolean isAdmin = false;
boolean isAdmin = false;
try
{
SecurityService sservice = (SecurityService) ruleProxy.getService(SecurityService.class);
isAdmin = sservice.isCurrentUserAdmin();
}
catch(Exception e)
{
e.printStackTrace();
}
return isAdmin;
}
}
}
Related KB Articles
Q113344Was this helpful?
Related Articles
Check whether the current user is admin or not through Evaluate custom rule 4Number of Views Determining Whether a Silent Install Was Successful 11Number of Views Determine If The User Launching Installer Is In The Administrators Group 3Number of Views A network drive mapped in VMware Tools is accessible only to Standard users, blocking access for InstallShield running as … 19Number of Views "Created By" field on a record may be set to the current user if the field is currently empty when the record is updated 4Number of Views
Revenera Assistant
Online
Hi, I am Reva - Ask me anything.
Updates
No new updates
Chat
Home
Updates
/**/
Thanks for the feedback!
Your feedback has been saved.Rate this response:
1
2
3
4
5
Add Additional feedback ( Optional )
0/240
English
English
Language changed successfully
Something went wrong
Email sent successfully
Something went wrong
Case create successfully
Are you sure you want to cancel
the case creation?
Please select a product to submit the case.
Please select a product version to submit the case.
0/255
Upload Attachment
File Upload
Maximum file
size allowed is 3 MB.
File type
not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
Are you sure you want to cancel the case creation?
Case closed successfully
File Upload
Maximum file size allowed is 3 MB.
File type not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
File Upload
Maximum file
size allowed is 3 MB.
File type
not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
© 2026 Flexera Software. All Rights Reserved.
Case id: 00001065
Activity: Status change: 2 hours ago