Revenera logo

Often times, custom code will need to pass an InstallAnywhere variable back in to the running installer. It is possible to set InstallAnywhere variables from within custom code by using the setVariable(String varName, Object value) method where ‘varName’ is the full variable name such as “$USER_INSTALL_DIR$” and value is an object containing the value to be stored within the InstallAnywhere variable.

All InstallAnywhere variables are stored as strings. Although an object can be stored to an InstallAnywhere variable, it will be converted to a string. The delimiter dollar signs must be included. The method is defined in multiple classes within the API, but it comes from the VariableAccess Interface. To set a sample variable, follow this:

package com.ia.kb;

public class SetAVariable extends CustomCodeAction
public void install( InstallerProxy ip) throws InstallException
ip.setVariable(“$MY_TEST_VAR$”, “Test value”);
public void uninstall (UninstallerProxy up) { }
public String getInstallStatusMessage() {return “My Action”; }
public String getUninstallStatusMessage(){return “My Action”; }

InstallShield icon


Create native MSIX packages, build clean installs, and build installations in the cloud with InstallShield from Revenera.

Doing so will set $MY_TEST_VAR$ within InstallAnywhere for use during the rest of the installation.

Have any tips or other questions on setting variables from within custom code? Let us know.


InstallAnywhere is the leading multiplatform development solution for application producers who need to deliver a professional and consistent cross installation experience for physical, virtual and cloud environments. From a single project file and build environment, InstallAnywhere creates reliable installations for on-premises platforms – Windows, Linux, Apple OS X, Solaris, AIX , HP-UX, and IBM iSeries – and enables you to take existing and new software products to a virtual and cloud infrastructure and build Docker containers.  Get your free trial of InstallAnywhere or contact us for more information.

InstallShield® is the world’s leading Windows installation development solution. InstallShield is designed to enable development teams to be more agile, collaborative and flexible when building reliable InstallScript and Windows Installer MSI installations for desktop, server, Web, virtual and traditional applications. The software installer of choice for today’s sophisticated application producers, InstallShield is the only software installer that can directly convert MSIs to Microsoft App-V virtual packages. Get your free trial of InstallShield today or contact us for more information.