Uninstallation Workflows
Relevant source files
The following files were used as context for generating this wiki page:
Uninstallation workflows in the auto-opsi-repo project provide standardized methods for removing Windows applications via OPSI scripts. The system uses PowerShell templates and a package catalog to handle diverse removal scenarios, including registry-based uninstalls, MSI de-registrations, and directory cleanup for portable applications. These workflows ensure that uninstallation is silent, verifiable, and consistent across different installer types.
Sources: README.md, builder/templates/uninstall.ps1
Core Logic and Execution Flow
The uninstallation process relies on the uninstall.ps1 script, which imports shared functions from runtime.ps1. The script reads the package configuration from config.json to determine the appropriate removal method.
The diagram shows the decision logic used by the PowerShell uninstaller to select and verify a removal method.
Sources: builder/templates/uninstall.ps1:1-30, builder/templates/runtime.ps1:1-5
Uninstallation Methods
The project supports six distinct uninstallation methods defined in the catalog/packages.yaml and executed by the PowerShell runtime.
| Method | Description | Primary Action |
|---|---|---|
registry | Searches HKLM (64-bit and 32-bit) for matching products. | Runs QuietUninstallString or UninstallString with silent args. |
msi | Targets a specific MSI ProductCode. | Executes msiexec.exe /x {ProductCode} /qn /norestart. |
vendor | Uses a specific executable path provided by the vendor. | Runs the file at uninstall.path with silent_args. |
command | Executes an arbitrary shell command. | Parses and runs the provided command string. |
zip | Cleans up portable/extracted applications. | Recursively deletes the installer.target_dir. |
msix | Manages modern Windows app packages. | Calls Remove-AppxProvisionedPackage. |
Sources: builder/templates/uninstall.ps1:6-31, README.md, catalog/packages.yaml
Registry-Based Removal
When using the registry method, the system scans SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall in both 64-bit and 32-bit registry views. It matches applications using the display_name_regex. If an entry identifies as a Windows Installer (MSI), the script automatically uses msiexec.exe for removal. Otherwise, it prioritizes the QuietUninstallString found in the registry.
Sources: builder/templates/runtime.ps1:9-40, builder/templates/uninstall.ps1:8-16
Cleanup and Verification
After the uninstallation command completes, the workflow executes a post-uninstall detection check. The InstalledVersion function is called; if it still returns a version string, the workflow throws an error, signaling that the removal failed even if the exit code was 0.
Sources: builder/templates/uninstall.ps1:33-34, builder/templates/runtime.ps1:43-51
Integration with Installation
The uninstallation logic is also utilized during the installation phase if the installer.uninstall_previous flag is set to true in the package catalog. This is critical for vendors that do not support seamless in-place upgrades.
This sequence illustrates how the uninstallation workflow is nested within the installation process for clean upgrades.
Sources: builder/templates/install.ps1:5-9, catalog/packages.yaml
Configuration Parameters
Uninstallation behavior is governed by the uninstall block in catalog/packages.yaml.
- method: The strategy used for removal (e.g.,
registry,msi). - display_name_regex: Regex used to identify the product in the registry.
- silent_args: A list of arguments passed to the uninstaller to suppress UI and reboots.
- product_code: The GUID for MSI-based removal.
- package_name: The identity used for MSIX deprovisioning.
Sources: catalog/packages.yaml, builder/builder/opsi.py:73-82
Summary
Uninstallation Workflows provide a robust mechanism for application removal by abstracting complex Windows uninstallation procedures into a set of declarative methods. By combining automated registry discovery with strict post-action verification, the system ensures that OPSI-managed clients maintain a clean state, whether performing a standalone removal or a pre-install cleanup.