param(
    [string]$ServiceName = "lk-lemmy"
)

$service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue

if (-not $service) {
    Write-Host "Service '$ServiceName' does not exist."
    exit 0
}

if ($service.Status -ne 'Stopped') {
    Stop-Service -Name $ServiceName -Force
    Start-Sleep -Seconds 2
}

sc.exe delete $ServiceName

Write-Host "Service '$ServiceName' removed successfully."