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

Setting an InstallAnywhere Variable from within Custom Code

Setting an InstallAnywhere Variable from within Custom Code

Summary

To set an InstallAnywhere Variable from within Custom Code, the setVariable(String varName, Object value) method can be used.

Synopsis

To set an InstallAnywhere Variable from within Custom Code, the setVariable(String varName, Object value) method can be used.

Discussion

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.

It is imperative to realize that all InstallAnywhere variables are stored as strings. Although an object can be stored to an InstallAnywhere variable, that object will be converted to a string. It is also important to note that the delimiter dollar signs must be included. Although the method is defined in multiple classes within the API, it comes from the VariableAccess Interface.

To set a sample variable:
package com.ia.kb;
import com.zerog.ia.api.pub.*;
 
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"; }
}

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

Related Documents

Methods of Setting InstallAnywhere Variables
Labels (1)
No ratings
Version history
Last update:
‎Nov 12, 2018 06:56 PM
Updated by: