Video Screencast Help
Symantec Appoints Michael A. Brown CEO. Learn more.

WiseScript - Evaluating Windows Installer Conditions

private Created: 03 Mar 2009
Language Translations
Richard Jeffrey's picture
+3 3 Votes
Login to vote

Use the Add Text to INSTALL.LOG script action to add commands to the installation log. This action is only available inside scripts you develop in WiseScript Express.

As your script runs on the destination computer, the installation log records each action your WiseScript makes to the system (installation of files, additions or changes to registry, and so on), including failures of actions to execute. For failures, it lists the reason for the failure. When the uninstaller for the WiseScript runs, it undoes each action recorded in the installation log, starting at the bottom of the log and working its way up. Typically, you add commands to the installation log to customize the uninstall process for your application. To stop and start writing to the installation log.

Here are some examples of how you could use the Add Text to INSTALL.LOG script action.

Normally, the uninstaller does not remove files that were installed to the Windows, Windows\System, or Windows\System32 directories. If you wanted these files to be removed, you could place an Add Text to INSTALL.LOG script line directly before the Install File(s) script lines that install files to one of these directories. In the Add Text to INSTALL.LOG dialog, you'd then enter the following text exactly as shown.

Non-System File: You could also add a line to the installation log that would execute a program during uninstall. If you execute a program during uninstall, the uninstaller pauses until the program finishes execution. To execute a program during uninstall, in the Add Text to INSTALL.LOG dialog, you'd enter the following line, customizing the program's pathname as necessary and adding any command line options. You'd have to enter it exactly as shown because it is case-sensitive: Execute path: %MAINDIR%\Remove.exe

If you wanted the uninstaller to remove not only those files that were installed, but also files that were subsequently added by your application, you could remove all the files and sub-directories within a specified directory. Use this option with caution because end users might have stored their own files in the directory. To do this, in the Add Text to INSTALL.LOG dialog, you'd enter the following line, customizing the pathname as necessary, including the wildcard information. You'd have to enter it exactly as shown because it is case-sensitive:

File Tree: %MAINDIR%\Data\Temp\*.*

If you wanted the uninstaller to remove not only the registry keys that were created during execution of the script, but also those registry keys that were subsequently added by your application, you can remove an entire registry key, including all the sub-keys and values that exist below that key. To do this, in the Add Text to INSTALL.LOG dialog, enter the following line, but customize the registry information as necessary. Enter it exactly as shown because it is case-sensitive:

RegDB TREE: SOFTWARE\Wise Solutions
RegDB Root: 2
where the RegDB Root value is one of the following:29
0 - HKEY_CLASSES_ROOT
1 - HKEY_CURRENT_USER
2 - HKEY_LOCAL_MACHINE
3 - HKEY_USERS

The Call DLL Function script action lets you call a .DLL function from your WiseScript. Your WiseScript can call functions in Win16 or Win32 .DLLs that the script has already copied to the destination computer. You can use these functions to customize the execution of the script. These can be .DLLs that you've written yourself, .DLLs specific to WiseScript Express, or Windows .DLLs. You can cause your script to branch based on the returned results of a .DLL by setting the Action to Start Block if Return Value True or Start While Loop.

This action is only available inside scripts you develop in WiseScript Express; see About WiseScript Express on page 8. You can call a .DLL directly from your Windows Installer installation instead of placing the call in a WiseScript .EXE. To do so, use one of the Call Custom DLL or Call DLL actions listed in MSI Script view of your main installation product.

If you are writing your own .DLL, you should use CALLBACK or WINAPI in the declaration of the .DLL, or your .DLL might not function properly. To help with your .DLL development, review some of the sample source code, such as GETCPU32.C, in the DLL directory inside the WiseScript Express application directory. The DLL directory also contains source code for other .DLL samples in C and Delphi. These .DLLs are examples that function properly within WiseScript Express. Calling Visual Basic ActiveX controls is not supported. In the Call DLL Function dialog, fill out these options:

  • DLL Pathname. Specify the pathname of the .DLL file or use variable substitution to build a pathname from variables.

Evaluate Windows Installer Condition

This action is only available inside scripts you develop in WiseScript Express. The Evaluate Windows Installer Condition script action evaluates a condition in the currentlyrunning Windows Installer installation. You enter a Windows Installer condition and choose a WiseScript variable to hold the result. It puts the value of 1 (true) or 0 (false) into the WiseScript variable. In the Evaluate Windows Installer Condition Settings dialog, fill out the following options:

  • Dest. Variable - Enter or select the name of a temporary WiseScript variable in which to store the result of the Windows Installer condition. The variable is set to 1 if the condition is true, or 0 if false.
  • Condition - Enter a condition to evaluate. This can be any condition that can be evaluated in Windows Installer. You can either enter the literal condition or use WiseScript variables enclosed in percent signs.

The Execute Program script action lets your script run another .EXE file.

The .EXE file can be a file already installed on the destination computer, a file you installed as part of this script, or a file you provide on a separate disk. This action is only available inside scripts you develop in WiseScript Express. Alternatively, you can use the Execute Program custom actions in MSI Script to accomplish the same goal in your main installation product. If the program you plan to execute is designed to pass back a return value, the resulting return value is put into the variable %INSTALL_RESULT% and the variable %PROCEXITCODE%. If the program passes back a return value, you must mark the Wait for Program to Exit checkbox. In the Execute Program Settings dialog, fill out the following options:

  • .EXE Path - Specify the path to the program to be executed or build a pathname using variable substitution, for example, %MAINDIR% to refer to the application directory. Using variable substitution ensures that the correct path is used regardless of where the end user installs your software.
  • Command Line - The command line options for the program you are calling, as if you were typing them in the Run dialog.
  • Default Directory - The directory that should be current when the .EXE file is executed. The script does the equivalent of a Change Directory command (cd) before launching the program. Browse to a directory that's part of your script. You can choose from directories that you created using the Create Directory script action.
  • Variables Added - List any variables created in the external program that are not present in the calling script.
  • Window Size - You can force the .EXE file to run in a maximized or a minimized window, or you can let it run in its default window. Choose Hidden to run the .EXE silently, which means it runs minimized and its task is not shown on the task bar.
  • Wait for Program to Exit - If this is marked, the script does not continue until the .EXE has exited. Make sure you mark this checkbox if the program returns a value to WiseScript Express. If the script does not wait for the program to exit, add the command line parameter -sms.

This script action uses the Windows ShellExecute call, which means that you can open documents as well as applications. When your script opens a document, the associated application is automatically launched.

The Exit Installation script action exits your WiseScript. No message is displayed to the end user with this script action unless you also set the RESTART variable. You can set the exit code, also called return code, of this script within this action. This action is only available inside scripts you develop in WiseScript Express.

Keep in mind that this will not exit the MSI installation that called this WiseScript; only the WiseScript .EXE is exited. In the Exit Installation dialog, fill out the following option:

  • Application Exit Code - If this script is called by another application,this is the return code that will be returned to the calling program. If the WISE_ERROR_RTN variable is already set, the value in WISE_ERROR_RTN does not override the Application Exit Code but is written to the installation log.

The Get Environment Variable script action copies a Windows environment variable to a script variable. Environment variables are listed in System control panel; the System Variables list in the Environment tab of the System control panel shows environment variables. This action is only available inside scripts you develop in WiseScript Express. For example, you could use the Get Environment Variable to run a batch file or other program in a DOS window from within the Windows Installer installation. To do this, you'd use Get Environment Variable to put the value of ComSpec into a WiseScript variable; for example, put it in %COMMAND%. ComSpec is a Windows variable that holds the path to command.com, the DOS command line environment.

You could then use the Execute Program action to call command.com by entering %COMMAND% in the .EXE Path field and the name of your batch file or program in the Command Line field in the Execute Program Settings dialog. You'd also add the /c as a command line option to cause the command line window to close when your program finishes execution. In the Get Environment Variable dialog, fill out the following options:

  • Environment Variable - The name of the Windows environment variable you want to retrieve.
  • Variable Name - The name of the script variable in which you want to store the value.
  • Default Value - The value, if any, that should be stored in the script variable specified above if the specified environment variable is not found.
  • Remove File Name - If the environment variable typically contains a path to a file name, and you want to obtain the path to the directory that contains the file, mark this checkbox. This does not apply to the default path. If you mark the Remove File Name checkbox, do not specify a file name in the Default Value field.