$ErrorActionPreference = "Stop"
$ServiceName = "ControlCmdAgent"

if (Get-Service -Name $ServiceName -ErrorAction SilentlyContinue) {
  Stop-Service -Name $ServiceName -Force -ErrorAction SilentlyContinue
  sc.exe delete $ServiceName | Out-Null
  Write-Host "Service removed: $ServiceName"
} else {
  Write-Host "Service not found: $ServiceName"
}
