Add service install/uninstall scripts to repo root
This commit is contained in:
parent
fcddfe215a
commit
3182ef655e
3 changed files with 75 additions and 0 deletions
29
uninstall-service.ps1
Normal file
29
uninstall-service.ps1
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#Requires -RunAsAdministrator
|
||||
|
||||
$ServiceName = "MailPrint"
|
||||
|
||||
$svc = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
if (-not $svc) {
|
||||
Write-Host "Dienst '$ServiceName' ist nicht installiert." -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($svc.Status -ne "Stopped") {
|
||||
Write-Host "Stoppe Dienst '$ServiceName'..." -ForegroundColor Cyan
|
||||
Stop-Service -Name $ServiceName -Force
|
||||
Start-Sleep -Seconds 3
|
||||
}
|
||||
|
||||
Write-Host "Entferne Dienst '$ServiceName'..." -ForegroundColor Cyan
|
||||
sc.exe delete $ServiceName | Out-Null
|
||||
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
$check = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
if ($check) {
|
||||
Write-Error "Dienst konnte nicht entfernt werden. Bitte manuell pruefen."
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Dienst '$ServiceName' erfolgreich deinstalliert." -ForegroundColor Green
|
||||
Loading…
Add table
Add a link
Reference in a new issue