When you create a PowerPack in the CapaInstaller Console, it gets an install script and an uninstall script built from a template. Both scripts have the same sections:
Section
What it contains
Edit it?
Param block
The parameters that CapaInstaller passes to the script: $Packageroot, $AppName, $AppRelease, $LogFile, $TempFolder, $DllPath and $InputObject.
No
#### VARIABLES ####
$global:DownloadPackage and $global:MinimumDiskspaceMB, followed by a # DO NOT CHANGE THESE VARIABLES block that copies the parameters into global variables.
Only the two settings
#### FUNCTIONS ####
PreInstall, Install and PostInstall in the install script, or PreUninstall, Uninstall and PostUninstall in the uninstall script. PreInstall and PreUninstall start with a free disk space check against $global:MinimumDiskspaceMB.
The two templates differ only in their function names and their defaults:
Setting
Install template
Uninstall template
$global:DownloadPackage
$true
$false
$global:MinimumDiskspaceMB
1500
0
#### MAIN #### runs the script in this order:
PreInstall (or PreUninstall).
Start-PSDownloadPackage, if $global:DownloadPackage is $true and the script runs through the CapaInstaller agent.
Install (or Uninstall).
PostInstall (or PostUninstall).
Exit-PSScript 0. If any step throws an exception that your code doesn’t catch, the script ends instead with Exit-PSScript and the exception’s HResult as the exit code.
Loads the CapaOne.ScriptingLibrary .NET assembly from $DllPath and creates the $cs object that every $cs.* helper call in a PowerPack script goes through.
Populates the $global:gs* variables (program paths, Windows directories, OS version and edition, computer hardware info, job configuration) and $global:AppLogFolder at the start of a PowerPack script.
Triggers the download of the package’s kit folder from CiBaseAgent, then polls the download progress once per second, logging it, until it reaches 100%.
Checks whether a service with the given name is registered on the system, by looking for its key under the SYSTEM\CurrentControlSet\Services registry path.
Kills every running process whose name contains processname as a substring (case-insensitive), not just an exact match — for example “chrome” would also match and kill a.
Checks whether a product with the given ProductCode GUID is currently installed, by querying Windows Installer’s product state directly — no MSI file needed, just the GUID.