The Package Scripts Page

The Package Scripts page displays the Pre-Script, Command Line Script, and Post-Script when applicable.

To display the Package Scripts page, click on the Scripts folder within the selected package in the left pane.


The following list describes the Package Scripts page fields and their functions.

Properties

Description

Execution directory

Displays the directory under which the selected script will execute, preventing the need for full paths in the script.

Type

Defines the script. The options available are:

  • Pre-Script: Tests the condition of the machine.
  • Post-Script: Performs operations, deletes files, starts services, or opens installers. This can take the form of a VB Script or JScript.
  • Command Line Script: Starts executable files. The format is the same as a standard .cmd or .bat file.
  • VB Script: Indicates the language option for the script.
  • JScript: Indicates the language option for the script.
  • .BAT file: Runs commands from the command prompt.

Template

Available for Post-Script type only. Provides an easy way to create scripts on Windows-based patches using simple .msi- or .exe- based software installation programs. For more information, see Using a Template to Add a Package Script.

Deployment Script

Contains the actual script to be executed.

Types of Package Scripts

There are three types of package scripts. These scripts can be written in Microsoft Visual Basic Script or Microsoft JScript.

For more documentation on scripting languages, refer to Introduction to Windows Script Technologies (https://docs.microsoft.com/en-us/previous-versions/tn-archive/ee176792(v=technet.10)).

A software package can have a maximum of one of each type of script. When all three scripts are present, they will be executed in the following order:

  1. Pre-Script: Tests for a condition or shuts down a service on a computer or device. If you're going to use command line scripts, you must enter a Pre-script, which should set return code values for PLCCAgent.SetReturnCode. These values are used later to return deployment results back to the Agent. See the code example below.
    Copy
    ' Create The Objects
    Set Shell = CreateObject("WScript.Shell"): Set FSO =CreateObject("Scripting.FileSystemObject")
    Set windir = FSO.GetSpecialFolder(0)
    If Err.number Then
        EMsg = "An error while attempting to create the required objects." & vbNewLine & _
            "Error Number: " & Cstr(Err.number) & vbNewLine & "Error Description: " &
                Err.Description & vbNewLine & vbNewLine
    & _
                "NOTE: Please verify that you have Windows Scripting Host 2.0 or higher installed."
        Err.Clear
    Else
            'Do other functions
    End If
    'Stop deployment for error
    If LenB(EMsg) Then
        PLCCAgent.SetReturnCode 1, EMsg
    Else
    'Success
        PLCCAgent.SetReturnCode 0, vbNullString
    End If
  2. You can substitute any error code listed on Microsoft Docs in place of '1' to produce a more specific error message.

  3. Command Line Script: Starts executable files. The format is the same as a standard.cmd or .bat file.
  4. Post-Script: Performs operations such as the deletion of files, starting services, or running an installer.

Unless the Execution directory option is selected and a valid directory is defined, all scripts run in the ROOT directory.

Editing a Package Script

You can create or edit a package script from the Package Scripts page.

Prerequisites:

A package for the patch has been created. Refer to Adding Packages for additional information.

Edit existing package script properties from the Package Scripts page.

  1. Expand the patch properties to Scripts in the left pane.
    Example: New Patch > Signatures > New Signature > Package > New Package > Scripts.
    The Package Scripts page opens.
  2. In the left pane select Scripts.
  3. Define the directory location.
    1. Select the Execution directory check box.
      The associated directory field becomes active.
    2. Type the directory location from which the selected script will execute in the associated directory field.
  4. Select the script type drop-down list items based on your needs. The following table describes each script type.
  5. Type

    Script Language

    Description

    Pre-Script

     

    Test the condition on the machine.

     

    VB Script

    VB Script Language option.

    JScript

    JScript Language option.

    Post-Script

     

    Performs operations, deletes files, starts services, or open installers.

     

    VB Script

    VB Script Language option.

    JScript

    JScript Language option.

    Command Line Script

     

    Starts executable files. The format is the same as a standard .cmd or .bat file.

    Tip: The Template button is available for the Post-Script type only and provides an easy way to create scripts on Windows-based patches using simple .msi- or .exe-based software installation programs. For more information, see Using a Template to Add a Package Script.

  6. [Optional] Use the Launch Editor to create a script.
    1. Click Launch Editor.
      A text editor opens.
    2. Edit the script as desired.
    3. Select File > Save.
      The text is saved.
    4. Select File > Exit.
      The text editor closes and the text displays within the Deployment Script panel.
  7. Click Validate.
    The package script is validated and a validation message appears.
  8. If a script error occurs, use the text editor to fix the script content prior to continuing.

  9. Click OK.
    The validation message closes.

The package script is edited.