Previous Section
 < Day Day Up > 
Next Section


Modifying Installation Scripts Using Script Editor

As we’ve seen, we can use SMS Installer’s graphical menus and attribute settings to configure our installation scripts to suit our specific needs. Under different circumstances, however, these tools might not give us all the control needed to fully customize our SMS Installer–generated script file. Likewise, specific situations might arise in which it’s more efficient or just faster and easier to use a scripting method to make changes.

It really doesn’t matter how we go about creating our scripted installation. Remember, we can generate our initial script using either the Repackage Installation Wizard or the Watch Application Wizard. These two methods are probably preferred, as they give us a good basic script that we can customize using the Script Editor utility. Or we can open the Script Editor interface to modify an existing script or even begin scripting from scratch. In this section we’ll explore Script Editor variables and actions and then look at how to modify installation scripts using Script Editor.

Script Editor Variables and Actions

The Script Editor provided by SMS Installer is a powerful scripting utility. It provides a vast array of variables and actions (SMS Installer commands) that let you optimize the script files used by the installation process. Script variables contain information about the installation being performed. We can use these variables to hold the information gathered from users about where to place files. Script variables can also be used to hold information about which files users want to install. Additionally, a number of predefined variables contain information about the target computer system on which you’re installing software.

Before we look at how to make modifications to a script using Script Editor, let’s review some common scripting variables and actions. The following tables aren’t intended as a comprehensive list of all the available variables and actions, but rather as a short list of those more commonly used.

More Info 

Refer to the SMS Installer Help for a comprehensive list of scripting variables and actions.

Table 14.1 lists several predefined variables and the values they are designed to return.

Table 14.1: Predefined variables

Variable

Returns

WIN

The path of the Windows directory—for example, C:\Windows.

SYS32

The system directory for Win32 files under Windows NT and higher—for example, C:\Winnt\System32.

TEMP

The path of the temporary directory on the reference computer. An application often uses this directory to store DLLs before referencing them.

CMDLINE

The command-line options that are passed to the SMS Installer– generated file.

PASSWORD

The installation password assigned to a password-protected installation.

As we write our script, we can have SMS assign values to existing variables or generate additional variables to perform functions or hold values. During the installation, we can create the variables SMS uses to perform various functions. For example, we can define the values for the four variables listed in Table 14.2 as part of the installation script or have SMS prompt for the values during execution of the installation script. SMS frequently uses these variables—note especially the DOBACKUP variable, which is used to support the SMS Installer rollback feature.

Table 14.2: Functional variables

Variable

Function

BACKUPDIR

Defines where the backup files should be located.

DOBACKUP

Enables the performance of a backup of all files replaced during an installation.

HELPFILE

Identifies the help file to be read and displayed during installation when the user clicks Help.

RESTART

Causes the system to be restarted when the script terminates. This variable is generally set automatically.

Defining Variables

As mentioned, you can also define your own variables in the script. You can use the Set Variable action or the Prompt For Text action from Script Editor. To create variables, follow these steps:

  1. In the Installation Expert interface, choose Script Editor from the View menu to display the Script Editor interface, shown in Figure 14.32.

    Click To expand
    Figure 14.32: The Script Editor interface.

    Note 

    If you previously closed SMS Installer from the Script Editor interface, when you next open SMS Installer, Script Editor appears with the Installation Script pane blank. If you open SMS Installer in the Installation Expert interface, it loads a default script, which is displayed in the Installation Script screen when you switch to Script Editor.

  2. In the Actions list, double-click the Set Variable action to display the Set Variable dialog box, shown in Figure 14.33.


    Figure 14.33: The Set Variable dialog box.

  3. Enter the name of the variable you want to create or select a variable to modify from the Variable drop-down list. Variable names must always begin with a letter, must be no longer than 14 characters, and must contain no special characters except underscores.

  4. In the New Value text box, enter the value you want to set the variable to.

  5. Select an operation that you want performed on the new value from the Operation drop-down list, if required. Operations include incrementing or decrementing a numeric value by 1, removing trailing backslashes, converting a value to all uppercase or lowercase, converting the path and filename to a short or long filename, or simply performing no action—the default.

    More Info 

    Refer to the SMS Installer Help for examples of how to use the different operations.

  6. Three check boxes appear at the bottom of the Set Variable dialog box: Append To Existing Value, Remove Filename, and Read Variable From Values File. If the variable you entered is a counter and you choose to increment or decrement its value, select the Append To Existing Value check box. You can also use this option to append a string value to the current string value. If you want to remove the filename from a value that has a full path, select the Remove Filename check box. If you want SMS Installer to read the variable’s value from a file, select the Read Variable From Values File select box. Selecting this option will cause the entered value to be ignored, so select this option only if you’re running your script from the command line.

  7. Click OK to close the Set Variable dialog box.

To create a variable named APPDIR, for example, in which you set the location of the application’s working directory, enter APPDIR as the variable name and an appropriate path such as C:\TechNet as the value. When you need to invoke this value in your script, reference the variable’s value by enclosing the variable name in percent signs. To create a BACKUP directory for rollback that’s a subdirectory of the path you entered for APPDIR, your script line would look like this:

Set Variable BACKUP to %APPDIR%\BACKUP

Set Variable is just one of the SMS Installer Script Editor actions. In the next section we’ll look at the more common Script Editor actions.

Common Script Editor Actions

The Script Editor window, shown in Figure 14.32, contains a list of SMS Installer Script Editor actions that the installation script can perform. In this section we’ll look at some of the more common actions and their functions. Table 14.3 lists these actions.

Table 14.3: SMS Installer Script Editor actions

Action

Description

Add to AUTOEXEC.BAT

Adds or replaces commands and environment variables in the Autoexec.bat file other than the PATH command.

Add to CONFIG.SYS

Adds device driver and other statements to the Config.sys file.

Call DLL Function

Calls specific Win16 and Win32 DLLs.

Check Disk Space

Performs a check of disk space to verify that there’s enough free space to complete the installation.

Check If File/Dir Exists

Checks whether a specified file or directory exists on the target computer.

Create Directory

Creates a new directory on the target computer.

Create Service

Creates a service on a target Windows computer.

Delete File(s)

Deletes specified files and directories from the target computer.

Edit Registry

Creates or deletes new keys and values in the registry on Windows 95 or later computers.

Else Statement

Inserts a logical ELSE statement into the script.

Execute Program

Calls an executable to run outside the actual scripted installation.

Exit Installation

Terminates and exits the installation.

If/While Statement

Inserts IF/WHILE logic into the script.

Install File(s)

Finds the source files used during installation and compresses them into the installer executable file. These files are uncompressed on the target computer when the script is run.

Prompt For Text

Generates a dialog box to prompt the user for text input such as a filename or directory path.

Remark

Adds comments to the script.

Rename File/Directory

Finds and renames a file or directory on the target computer.

Set Variable

Creates or modifies a script variable.

As you can see, variables and actions can be set in your script. You can find more details about these options in the SMS Installer Help file accessible through the SMS Installer interface. Don’t expect to become proficient at scripting in a couple of hours or even a couple of days. We’re talking about a scripting language here, and that takes time to learn and appreciate. But with a little perseverance you’ll become proficient at using many of these options.

Modifying the Script

Now let’s take a look at how to make some simple modifications to our script using Script Editor. To do so, follow these steps:

  1. In the Installation Expert interface, choose Script Editor from the View menu to display the Script Editor interface, shown previously in Figure 14.32.

  2. Choose Open from the File menu to display the Open dialog box, shown in Figure 14.34, and then select a script (.IPF) file to open for editing. For this example, we’ll use the script we created earlier. Click Open to open the script for editing.

    Click To expand
    Figure 14.34: The Open dialog box.

  3. Next we’ll edit the variable that specifies the installation directory the program will use. In this example we’re installing to the Microsoft TechNet directory. We’ll change this to TechNet.

    Choose Find from the Edit menu to display the Find Text In Installation Script dialog box, shown in Figure 14.35. Enter Maindir in the Find What text box, and then click Find Next. The first instance of a script line containing “Maindir” is selected. This is the variable setting for the directory location of the Office installation we want to modify. Click Close to close the dialog box.

    Click To expand
    Figure 14.35: The Find Text In Installation Script dialog box.

  4. Click Edit Script Item button on Installation toolbar or double-click the Set Variable statement containing “Maindir” to display the Set Variable dialog box, shown in Figure 13-36. In the New Value text box, enter TechNet and then click OK. The variable setting is modified in the Installation Script pane of the Script Editor interface.


    Figure 14.36: The Set Variable dialog box.

You’d accomplish any additional script modifications in much the same manner. After we’ve completed our editing of the script, we’re ready to test and compile the installation script file. This will give us the SMS Installer–generated executable file.

Windows Installer Step-Up Utility Buttons

The Script Editor also offers three buttons that you can use to assist you in creating and testing Windows Installer packages. These are the three buttons at the far right of the toolbar in the Script Editor interface as seen previously in Figure 14.32. They are (in order from left to right as seen in the Script Editor window):

  • Compile As Windows Installer Package Lets you create a new Windows Installer package or convert an existing SMS Installer package to a Windows Installer package.

  • Run As Windows Installer Package Lets you run the Windows Installer package you create on the reference computer exactly as it would run on the target computers.

  • Uninstall Windows Installer Package Lets you remove a Windows Installer package that you installed on the reference computer using the Run As Windows Installer Package button.

The use of these buttons is fairly straightforward. You need to have opened or created an SMS Installer or Windows Installer script—an .IPF file. Then click the appropriate button to carry out the task. A command-line version of the Windows Installer Step-Up Utility is also included when you install SMS Installer on the reference computer. Selecting the option ISU Command-Line Utility in the Microsoft SMS Installer program group displays a command prompt window, shown in Figure 14.37, that lists the command-line options that are available and the command syntax, and that places the command prompt in the appropriate directory to run the utility. You can also refer to the SMS Installer Help for detailed instructions for using the Windows Installer Step-Up Utility.

Click To expand
Figure 14.37: Windows Installer Step-Up Utility command prompt window.


Previous Section
 < Day Day Up > 
Next Section