Common Code Section

This section contains most of the actual code that the script runs. It expects to receive the name of an option and an index as parameters. It also checks to see that the language specified in STF_LANGUAGE is supported. It then checks the NTN_InstallMode variable to determine what it should do. Before proceeding to the section of code that will complete the required task, the script sets up default values for all the variables of the particular option being installed.

Main Entry Section

This section checks the value of the NTN_InstallMode variable and determines the label of the code that will complete that operation. It also assigns defaults values for the variables.

Set Defaults (set_defaults)

This section sets the default values for the options; among them are the service name, title, and description. These three must be set in this section; however, more variables can be added as needed.

Install Component (install_component)

This section checks to see if there are any instances of this component already installed. If there are none, it sets the install index to one and continues. Otherwise, if one instance exists, it checks for the value of the ProductExclusive variable to determine what it should do. If it needs to install another instance of the component, it executes the utility file and finds the next available index to use.

When it is ready, the script determines the service name for this component using an algorithmic definition (install_nextstep). If the ProductServiceQuery variable is set to TRUE, the user is presented with this value and is allowed to change it. When all the variables are ready, it proceeds to the parameter modification section.

Configure Component (config_component)

This section determines whether or not the component in question is installed. If the component is not installed or if the index is invalid, it fails with an error. Otherwise, it reads the parameters for this component from the registry (read_params). This code reads the parameters from the Parameters and ExtraParameters keys in the registry and creates a list of their values. It then loops through the list and assigns the values to the variables using a switch/case construct (assign_value_option). When that is done, there is an extra section (assign_extra_option) where other parameters that do not reside in the standard location can be read or any other code that assigns values to variables can be placed. When the variables are all assigned, the code proceeds to the parameter modification section.

Modify Parameters (modify_params)

This section contains the code that modifies the variables or calls out other code that modifies them. As soon as this section is entered, control is routed to subsections, one for each option (modify_params_option). These subsections should contain all of the actual modification code. When this section is done, the variables are ready to write to the registry and the code proceeds to the adjustment section.

Adjust Parameters (adjust_params)

This section takes control from the parameter modification section. If the script is supposed to configure an existing component, the control is routed directly to the code that writes the parameters to the registry. Otherwise, control falls to code that creates the appropriate service entries in the registry before it writes out the variables.

Create Registry Entries (create_regvals)

This section creates the service and registry entries for this component. It also writes out some of the values that the product entry under the SOFTWARE\Microsoft key needs to contain. This section is also currently in charge of the NCPA bindings information. If the product files have not been copied, this code shells out to the installation section that handles file copying (InstallRemove). When all the keys are created, control falls to the section that writes out the variable values to the registry.

Write Out Variables (write_params)

This section first ensures that the appropriate handles are open and then routes control to a subsection that prepares the appropriate variables for registry output (write_params_option). Each of these sections must prepare the ProductParams and ProductExtraParams variables to be written to the registry. Each of these parameters is a list of registry creation lists. Each registry creation list must contain the name of the entry to be created, the NoTitle variable, the type of entry to create, and the value of the entry. See the existing link service .INF scripts.

The ProductParams variable must contain the name and option entries. Both variables can contain any additional entries that are needed. Also, any other parameter-writing code should be written in these sections. For an example, see the setup script for the NDIS 802.2 link support (SNADLC.INF).

After the subsections are finished, control is passed to the code that actually adds the list of entries to the registry. It also prepares the data return structure and finishes by using the successful escape hatch.

Get Bindings From Component (getbind_component)

This section is responsible for communicating the option bindings back to SNA Server Setup. It queries the NCPA bindings, sets the information in the data return structure, and returns it to SNA Server Setup. SNA Server Setup then uses this information to determine whether this particular instance can be removed or not. An instance can be removed if it is not needed (bound to) by any other component.

Remove Component (remove_component)

This code is in charge of removing one or all of the instances for a particular product. In the case of a complete removal, it also removes the files and software entries for this product. In the case of a single instance removal, the code passes control to the remove_one_piece subsection, which handles a single removal. Otherwise, code control goes to the remove_all_pieces subsection.

For a full removal, the setup script loops through all of the instances and calls the remove_one_piece subsection for each of those instances. When the loop is complete, the code control is passed to a common point for both removal types (remove_product). The subsection remove_one_piece removes the software entry for the instance and deletes the service from the Service Control Architecture. If it is dealing with a complete removal, it returns control to the loop, otherwise, it falls to the remove_product subsection. This subsection determines whether files should be removed (full removal) and calls the appropriate installation section (InstallRemove). After all is done, it uses the successful escape hatch to return control to SNA Server Setup.

Escape Hatches

These are all the available hatches that can be used throughout the setup script.

Successful (successful)
Sets the status to STATUS_SUCCESSFUL and exits through end.
Warning Message (warning_msg)
This hatch displays a warning dialog box with the error message stored in the variable Error. This variable should be defined before calling this escape hatch. This warning dialog box has two dialog buttons: OK and Cancel. If the user chooses to continue, control is passed to the to label, otherwise, control is returned to the from label. If the warning box fails, the script exits through end.
Nonfatal Message (nonfatal_msg)
This hatch displays a nonfatal warning dialog box with the error message stored in the variable Error. This variable should be defined before calling this escape hatch. This dialog box has only one button, OK. After the user presses this button, control is returned to the from label. If the nonfatal warning dialog box fails, the script exits through end.
Fatal Registry Message (fatal_registry)
This is probably the most-used escape hatch, next to the successful hatch. It sets up the Error variable with a template that includes three other variables: ErrMesg, ErrProc, and ErrFunc. The first should be a short message describing the error. The second should be the section or subsection that called the registry function. The third should be the name of the registry function that was called. All three variables should be set before calling this escape hatch. After the error message is prepared, the fatal_msg escape hatch gets control.
Fatal Message (fatal_msg)
This hatch displays a dialog box with the fatal error message. When the user clicks the button, this hatch exits through the set_status_failed escape hatch.
Shell Code Error (ShellCodeError)
This hatch is only used when a shell execution fails. If the script receives a ShellCode that is not zero, it calls this hatch. This hatch displays an error message and exits through the set_status_failed hatch.
Failed Exit (set_status_failed)
This hatch sets the status to STATUS_FAILED and exits through end.
End
This hatch ensures that the handle to the SRL for this file is closed and exits this script. It should not be called directly without ensuring that the Status variable contains the correct return value for the operation.