mirror of
https://github.com/fleetdm/fleet
synced 2026-05-02 10:57:25 +00:00
This pull request adds support for managing OBS Studio on Windows using Winget, including new install and uninstall scripts for automated deployment and removal. The main changes are the introduction of a metadata file for OBS Studio and robust PowerShell scripts to handle silent installation and uninstallation. **OBS Studio Winget Integration:** * Added a new metadata file `obs.json` describing OBS Studio for Winget management, including identifiers, script paths, and default categories. **Installation Script:** * Introduced `obs_install.ps1`, a PowerShell script that installs OBS Studio silently using the `/S` flag, captures the installer exit code, and handles errors gracefully. **Uninstallation Script:** * Added `obs_uninstall.ps1`, a PowerShell script that locates the OBS Studio uninstaller via the Windows registry, ensures all running OBS processes are stopped, parses the uninstall command, and performs a silent uninstall (also with `/S`), including error handling and exit code reporting.
81 lines
2.4 KiB
PowerShell
81 lines
2.4 KiB
PowerShell
# Attempts to locate OBS Studio's uninstaller from registry and execute it silently
|
|
|
|
$displayName = "OBS Studio"
|
|
$publisher = "OBS Project"
|
|
|
|
$paths = @(
|
|
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
|
|
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
|
|
)
|
|
|
|
$uninstall = $null
|
|
foreach ($p in $paths) {
|
|
$items = Get-ItemProperty "$p\*" -ErrorAction SilentlyContinue | Where-Object {
|
|
$_.DisplayName -and ($_.DisplayName -eq $displayName -or $_.DisplayName -like "$displayName*") -and ($publisher -eq "" -or $_.Publisher -eq $publisher)
|
|
}
|
|
if ($items) { $uninstall = $items | Select-Object -First 1; break }
|
|
}
|
|
|
|
if (-not $uninstall -or -not $uninstall.UninstallString) {
|
|
Write-Host "Uninstall entry not found"
|
|
Exit 0
|
|
}
|
|
|
|
# Kill any running OBS processes before uninstalling
|
|
Stop-Process -Name "obs64" -Force -ErrorAction SilentlyContinue
|
|
Stop-Process -Name "obs32" -Force -ErrorAction SilentlyContinue
|
|
|
|
$uninstallString = $uninstall.UninstallString
|
|
$exePath = ""
|
|
$arguments = ""
|
|
|
|
# Parse the uninstall string to extract executable path and existing arguments
|
|
# Handles both quoted and unquoted paths
|
|
if ($uninstallString -match '^"([^"]+)"(.*)') {
|
|
$exePath = $matches[1]
|
|
$arguments = $matches[2].Trim()
|
|
} elseif ($uninstallString -match '^([^\s]+)(.*)') {
|
|
$exePath = $matches[1]
|
|
$arguments = $matches[2].Trim()
|
|
} else {
|
|
Write-Host "Error: Could not parse uninstall string: $uninstallString"
|
|
Exit 1
|
|
}
|
|
|
|
# Build argument list array, preserving existing arguments and adding /S for silent
|
|
# NSIS installers require /S flag for silent uninstall
|
|
$argumentList = @()
|
|
if ($arguments -ne '') {
|
|
# Split existing arguments and add them
|
|
$argumentList += $arguments -split '\s+'
|
|
}
|
|
# Append /S if not already present
|
|
if ($argumentList -notcontains "/S" -and $arguments -notmatch '\b/S\b') {
|
|
$argumentList += "/S"
|
|
}
|
|
|
|
Write-Host "Uninstall executable: $exePath"
|
|
Write-Host "Uninstall arguments: $($argumentList -join ' ')"
|
|
|
|
try {
|
|
$processOptions = @{
|
|
FilePath = $exePath
|
|
NoNewWindow = $true
|
|
PassThru = $true
|
|
Wait = $true
|
|
}
|
|
|
|
if ($argumentList.Count -gt 0) {
|
|
$processOptions.ArgumentList = $argumentList
|
|
}
|
|
|
|
$process = Start-Process @processOptions
|
|
$exitCode = $process.ExitCode
|
|
|
|
Write-Host "Uninstall exit code: $exitCode"
|
|
Exit $exitCode
|
|
} catch {
|
|
Write-Host "Error running uninstaller: $_"
|
|
Exit 1
|
|
}
|
|
|