Getting Started with VB Scripting
This page explains the skeleton that every VBScript package starts from, and the conventions used throughout the VB Scripting Library reference. Read this first if you are about to write your first package — the function reference assumes you already know this.
How a package is created
Section titled “How a package is created”A VBScript package is not written from scratch — it is generated by Package Creator: right-click Packages → Create package, pick a template (Basic, Generic Installer, MSI, InstallShield, App-V, Thinstall, …), fill in the wizard, and click Generate. This produces the .cis script(s) for the package — typically an install script, an uninstall script, and (if the package needs one) a user setup script — already wired up with the skeleton below. You then edit the generated script to add your own install/uninstall logic; you don’t write the skeleton yourself.
The standard skeleton
Section titled “The standard skeleton”Every generated script — regardless of which template you picked — follows the same shape. Using a Basic install script as an example:
Dim bStatus
Private Function IncludeScript(sScriptFile) '... (generated boilerplate that loads the script; never edit this function)End Function
Function Install()Dim bStatus'Begin bStatus=True ' <- your install logic goes here Install=bStatusEnd Function
Function CustomPreInstall()Dim bStatus'Begin bStatus=True ' <- optional: anything that must run before Install() CustomPreInstall=bStatusEnd Function
Function CustomPostInstall()Dim bStatus'Begin bStatus=True ' <- optional: anything that must run after Install() CustomPostInstall=bStatusEnd Function
'Begin main bStatus=True If bStatus Then bStatus=IncludeScript("customlib.cis") If bStatus Then bStatus=IncludeLibrary("capalib.cin")
If bStatus Then bStatus=Job_SetPlatform("CDM") If bStatus Then bStatus=Job_Start("WS","Clean VB","v1","Clean VB.Log","INSTALL") If bStatus Then bStatus=Job_AttendedInstallation() If bStatus Then bStatus=Job_SetLanguage("OS") If bStatus Then bStatus=Sys_GetFreeDiskSpace("C:",10) If bStatus Then bStatus=CDM_DefineEndUserCancellation(9999,99991231,"ALWAYS") If bStatus Then bStatus=Job_SetStartTime() If bStatus Then bStatus=CustomInit("Clean VB") If bStatus Then bStatus=CDM_DownloadPackageBeforeInstall(25,gsTempDir) If bStatus Then bStatus=CustomPreInstall() If bStatus Then bStatus=Job_InstallationStart("Clean VB","5",10,2) If bStatus Then bStatus=Install() If bStatus Then bStatus=CustomPostInstall() If bStatus Then bStatus=CDM_RemoveLocalPackage(gsTempDir) bStatus=Job_InstallationCompleted("Clean VB",bStatus) Job_End(bStatus)'End MainWhat each step does
Section titled “What each step does”| Step | Purpose |
|---|---|
IncludeScript("customlib.cis") / IncludeLibrary("capalib.cin") |
Loads the customer-specific module and the CapaInstaller Scripting Library itself. Generated as-is — never edit. |
Job_SetPlatform("CDM") |
Always "CDM" for a normal CapaInstaller package. Leave it as generated. |
| Job_Start | Initializes the job: sets up logging, and everything downstream (including the gs/gb globals in Variables) depends on this having run first. |
Job_AttendedInstallation() / Job_SilentInstallation() |
Declares whether this run shows UI to the end-user or runs silently — which one is generated depends on the package type/template you picked. |
Job_SetLanguage("OS") |
Sets the language used for any built-in end-user messages. |
| Sys_GetFreeDiskSpace | Aborts the install early if there isn’t enough disk space. |
CDM_DefineEndUserCancellation, CDM_DownloadPackageBeforeInstall, CDM_RemoveLocalPackage |
Standard bookkeeping steps generated by Package Creator (end-user cancellation window, staging the package locally before install, cleaning up the local copy afterward). Treat these as boilerplate — leave them as generated rather than tuning their parameters by hand. |
Job_SetStartTime() |
Marks the start time used for install duration reporting. |
CustomInit(sPackageName) |
A hook from customlib.cis, not the Scripting Library itself. Always takes the package’s name as its only parameter. |
CustomPreInstall() / CustomPostInstall() |
Your two customization hooks — add anything that needs to happen immediately before/after the main install logic. |
Job_InstallationStart(...) |
Marks the point where the actual install work begins (used for progress reporting). |
Install() / Uninstall() |
The function you actually edit: this is where your package’s real logic goes. |
| Job_ActivateUserSetup / Job_RemoveUserSetup | Only present if the package has a user setup script — registers/removes the per-user part of the install. |
| Job_InstallationCompleted | Reports the overall install result. |
| Job_End | Always the last call. The bStatus value passed here is what the CapaInstaller Console shows as the package’s success/failure status. |
The bStatus convention
Section titled “The bStatus convention”Almost every line in a CapaInstaller script looks like this:
If bStatus Then bStatus=SomeFunction(...)Every Scripting Library function returns True or False depending on whether it succeeded. This line means: “only run SomeFunction if everything so far has succeeded, and record whether it succeeded too.” Once bStatus becomes False, every subsequent If bStatus Then ... line is skipped — this is a manual short-circuit, not a language feature, so it has to be written out on every single line. Whatever bStatus holds when it reaches Job_End(bStatus) at the very end is what determines whether the CapaInstaller Console marks the package as succeeded or failed.
The gbValue/gsValue convention
Section titled “The gbValue/gsValue convention”Many functions don’t return their result directly — instead they return True/False for “did this step succeed,” and put the actual result in the global gbValue (Boolean) or gsValue (String), which you read immediately afterward:
If bStatus Then bStatus=Sys_GetFreeDiskSpace("C:",10)' the disk-space check's own result is now in gbValue, not in bStatusThis is the same pattern used throughout the Library (see Variables for the full list of gs/gb/gi globals populated this way).