Scripting Objects

Scripts can interact with the Silent Install Builder Installer using a number of different objects. For example, the Session object represents an Installation session providing information about executed actions and letting the script to interact with the User.

Session object

The Session is a global object can be accessed from Script Action or Condition code.

Data

Defines the JavaScript Oblect used to pass some data across actions within the session.


    //Defines new property and set the value
    session.Data.myProperty = 42;
    //Retrieve the property value
    //This can be called from another action or condition 
    session.Log(session.Data.myProperty);

ExtArgs

Returns a command line arguments passed to the Installer with /p parameter. This is a read-only property.


    //Get the command line arguments
    if(session.ExtArgs){
        session.Log("The arguments passed to the package: " + session.ExtArgs);
    }

LastActionResult

Gets the result of previous executed action. This is a read-only property.

Returns


    //Get the result of prev. executed action
    var res = session.LastActionResult;
    if(res && res.Errors){
        session.Log(res.ActionName + " failed. error: " + res.Errors);
    }

Log()

Writes the Log row to the log output.

Parameters

  • string string to log

Example


      session.Log("Action started");

UserMessage()

Shows the Message box with Warning icon and the OK button.

Parameters

  • string message to show

Example


    session.UserMessage("Action failed");

Sib object

The Sib is a global object can be accessed from Script Action or Condition code. It provides core functionality of the Silent Install Builder Installer. Contains methods to operate on Processes, File System and Registry.

ExecuteProcess()

Starts a process by specifying the path of an application and a set of command-line arguments.

Parameters

  • path (string) The file path to execute.
  • args (string) Command-line arguments.

Returns

Example


    //Run Powershell script file and get the exit code.
    var res = Sib.ExecuteProcess("powershell.exe", "-ExecutionPolicy Bypass -file test.ps1");
    if(res.ExitCode != 0){
        session.Log(res.ActionName + " failed.);
    }

ExecuteProcessNoWait()

Starts a process by specifying the path of an application and a set of command-line arguments. No waiting for process complete.

Parameters

  • path (string) The file path to execute.
  • args (string) Command-line arguments.

Returns

Example


    //Run Notepad and open the file
    Sib.ExecuteProcessNoWait("notepad.exe", "log.txt");

ActionResult object

A helper object that represent a return value of methods ExecuteProcess() and LastActionResult property.

ActionName

The name of executed action.

Returns

  • string

ExitCode

Exit Code of executed process.

Returns

  • int

ConsoleOut

Console Output of executed process.

Returns

  • string

Errors

Contains string of errors. If no errors occurs value is empty.

Returns

  • string