# Stop ThreatLocker Service Stop-Service -Name "ThreatLockerService" -Force -ErrorAction SilentlyContinue # Disable Service Startup Set-Service -Name "ThreatLockerService" -StartupType Disabled -ErrorAction SilentlyContinue # Locate UninstallString from Registry $TLKey = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.DisplayName -like "*ThreatLocker*" } if ($TLKey) { # If an uninstall password was NOT set by the prior MSP, unattended flag works: $UninstallString = $TLKey.UninstallString if ($UninstallString -match "msiexec") { # Extract ProductCode GUID $Guid = ($UninstallString -split " ")[1] Start-Process "msiexec.exe" -ArgumentList "/x $Guid /qn /norestart" -Wait } else { Start-Process -FilePath $UninstallString -ArgumentList "/uninstall /quiet" -Wait } } # Clean lingering directories if driver/service is removed $TLPaths = @( "C:\Program Files\ThreatLocker", "C:\ProgramData\ThreatLocker" ) foreach ($Path in $TLPaths) { if (Test-Path $Path) { Remove-Item -Path $Path -Recurse -Force -ErrorAction SilentlyContinue } }