Add Windows service host and system tray controller
All checks were successful
CI / test (push) Successful in 7s

This commit is contained in:
Space-Banane
2026-05-28 13:30:27 +02:00
parent 314311d8fc
commit 114ddd80d6
13 changed files with 803 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[string]$ServiceName = "ScreenJobBackend"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Test-IsAdministrator {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (-not (Test-IsAdministrator)) {
throw "Run this script from an elevated PowerShell session (Run as Administrator)."
}
$service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if ($null -eq $service) {
Write-Host "Service '$ServiceName' is not installed."
exit 0
}
if ($PSCmdlet.ShouldProcess($ServiceName, "Uninstall service")) {
if ($service.Status -ne "Stopped") {
Stop-Service -Name $ServiceName -Force -ErrorAction Stop
}
& sc.exe delete $ServiceName | Out-Null
if ($LASTEXITCODE -ne 0) {
throw "Failed to delete service '$ServiceName' (sc.exe exit code $LASTEXITCODE)."
}
}
Write-Host "Service '$ServiceName' uninstalled successfully." -ForegroundColor Green