Skip to content

OSD Scripting Guidelines

Scripting Guidelines for using CapaInstaller Scripting Library

Section titled “Scripting Guidelines for using CapaInstaller Scripting Library”

The OSD library can be included in the following predefined OSD Scripts used by OSDGui during the WinPe (boot media) phase of the Operating Systems Deployment process.

  • PreGUIScript.wsf
  • PreInstallScript.wsf
  • PreDiskPartScript.wsf
  • PreImageScript.wsf
  • PreDriverCopyScript.wsf
  • PrePatchScript.wsf
  • PreBootScript.wsf

You create and edit the scripts per OS Deployment point in the CapaInstaller Console, see Create a new script. During deployment, the OSD client downloads the scripts to X:\Scripts in WinPE. It downloads the scripting libraries from the OSD server to X:\Program Files\CapaInstaller\Client\Lib, so you don’t have to copy the libraries yourself.

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

Private Function IncludeScript(sScriptFile)
Dim sCmd
Dim sClientDir
Dim sScriptDir
'Begin
bStatus=True
On Error Resume Next
Dim oLocalShell : Set oLocalShell=CreateObject("WScript.Shell")
Dim oLocalFso : Set oLocalFso = CreateObject("Scripting.FileSystemObject")
sScriptDir = Mid(WScript.ScriptFullName,1,Len(WScript.ScriptFullName)-Len(WScript.ScriptName)-1)
sClientDir=oLocalShell.RegRead("HKLM\Software\CapaSystems\CapaInstaller\Client Directory")
If bStatus and (sClientDir<>"") Then
If oLocalFso.FileExists(sClientDir & "\Lib\" & sScriptFile) Then
sCmd = oLocalFSO.OpenTextFile(sClientDir & "\Lib\" & sScriptFile,1).ReadAll
ElseIf oLocalFso.FileExists(sScriptDir & "\" & sScriptFile) Then
sCmd = oLocalFSO.OpenTextFile(sScriptDir & "\" & sScriptFile,1).ReadAll
End If
Else
bStatus=False
End If
ExecuteGlobal sCmd
IncludeScript=bStatus
End Function
'Begin
bStatus=True
If bStatus Then bStatus=IncludeScript("customlib.cis")
If bStatus Then bStatus=IncludeLibrary("Capalib.cin")
If bStatus Then bStatus=IncludeLibrary("Osdlib.cin")
If bStatus Then bStatus=Job_Start("WS","Script Name","1.0","ScriptName.log","INSTALL")
If bStatus Then bStatus=OSD_Initialize()
'Place your own code here
Job_End(bStatus)
'End main

The function IncludeScript includes the customer-specific CapaInstaller module CustomLib.cis.
The function IncludeLibrary includes the CapaInstaller Scripting library and the CapaInstaller OSD library (this function is located in the customlib.cis).
 
Before CapaInstaller functions can be used the CapaInstaller Scripting 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.
Before OSD specific functions can be used, the CapaInstaller OSD Scripting library must be initialized. This is done from the function call OSD_Initialize.

IncludeScript first looks for the file in the Lib folder of the client directory, and then in the folder of the running script. To use your own functions from the OSDCustomLib script of the OS Deployment point, include it after the libraries:

If bStatus Then bStatus=IncludeScript("OSDCustomLib.cis")

Job_Start, Job_End and OSD_Initialize function description for further details. Constants Package Property Variables