Scripting Guidelines

Scripting Guidelines for using CapaInstaller Scripting Library

Through years of experience in scripting, CapaSystems has developed a concept for making safe scripting.
This help file describes in detail the core script component called CapaInstaller Scripting Library. CapaInstaller Scripting Library is a function library where standard VBS (Visual Basic Scripting) functions has been wrapped in jacket routines. The reasons to do so are many: handle the deployment log, secure deployment integrity, more simple and standardized code etc.

To include the CapaInstaller Scripting Library, in the script, you must include the following code in the script:

Dim bStatus
 
Private Function IncludeScript(sScriptFile)
Dim oLocalFso
Dim sCmd
Dim sClientDir
Dim oLocalShell
'Begin
  bStatus=True
  On Error Resume Next
  Set oLocalShell=CreateObject("WScript.Shell")
  sClientDir=oLocalShell.RegRead("HKLM\Software\CapaSystems\CapaInstaller\Client Directory")
  If bStatus and (sClientDir<>"") Then
    Set oLocalFso = CreateObject("Scripting.FileSystemObject")
    sCmd = oLocalFso.OpenTextFile(sClientDir & "\Lib\" & sScriptFile,1).ReadAll
  Else
    bStatus=False
  End If
  ExecuteGlobal sCmd
  IncludeScript=bStatus
End Function
 
Function Install()
Dim bStatus
bStatus=True
'Begin
  
  'Place your own code here
 
  Install=bStatus
End Function

'Begin
  bStatus=True
  If bStatus Then bStatus=IncludeScript("Includes.cis")
  If bStatus Then bStatus=IncludeScript("customlib.cis")
  If bStatus Then bStatus=IncludeScriptingLibrary("CapaInstaller Scripting Library.cin")
  If bStatus Then bStatus=Job_Start("WS","Demo script","1.0","DemoScript.log","INSTALL")

  If bStatus Then bStatus=Install()

  Job_End(bStatus)
'End main

Script Comments:

The function IncludeScript includes the customer-specific CapaInstaller module CustomLib.cis and the standard library includes.cis. Includes.cis contains a function to include the CapaInstaller Scripting library.
 
Before CapaInstaller functions can be used the library must be initialized. This is done from the function call Job_Start. When a Job has finished the function Job_End must be called.
See Job_Start and Job_End function description for further details.