|
Variables Method |
Top Previous Next |
|
Gets or sets the installer variables. [VBScript] sVar = Installer.Variables(sVarName) Installer.Variables(sVarName) = sNewVar
[JScript] sVar = Installer.Variables(sVarName); Installer.Variables(sVarName) = sNewVar; Parameters sVar The returned AWinstall variable value. sVarName The variable name (for example, "SystemPath"). sNewVar The new variable value. Remarks This method provides the access to installer variables. You may obtain the value of the built-in installer variable ("ProductName", for example), or you may create your own variables and use it later. The method supports also Registry and Environment Pseudo-Variables. For example, Installer.Variables("ENV:USERNAME") returns the contents of the USERNAME environment variable. Uninstall support This action does not support uninstallation. Example (VBScript) In this example the script tries to create the MS Word executable using ActiveX Automation. In success, it will create the new installer variable, "MSTemplatePath", which may be used later for extracting MS Word templates. On Error Resume Next Set obj = CreateObject("Word.Application") If Err.number<>0 Then ShowError "Can not find MS Word installed." & vbCrLf & "Cancel Install?" Else Installer.Variables("MSTemplatePath") = obj.Options.DefaultFilePath(2) obj.Quit Set obj = Nothing End If Sub ShowError(msg) res = Installer.ShowMessage(msg, "System checks", vbYesNo+vbExclamation) If res = vbYes Then Installer.CancelInstall End If End Sub Example (JScript) This example obtains and displays the path to the Windows System folder. sysPath = Installer.Variables("SystemPath"); Installer.ShowMessage("System path is: \n" + sysPath, "Message", 0); |