Documentación, scripts auxiliares y limpieza de archivos eliminados
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
param(
|
||||
[string]$ServiceName = 'AbogadasLitoralScheduler',
|
||||
[string]$NssmPath = 'C:\nssm\win64\nssm.exe'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Test-Admin {
|
||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
|
||||
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
}
|
||||
|
||||
if (-not (Test-Admin)) {
|
||||
throw 'Este script requiere PowerShell ejecutado como Administrador.'
|
||||
}
|
||||
|
||||
if (-not (Test-Path $NssmPath)) {
|
||||
throw "No se encontro nssm.exe en: $NssmPath"
|
||||
}
|
||||
|
||||
$service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
if (-not $service) {
|
||||
Write-Output "El servicio $ServiceName no existe."
|
||||
exit 0
|
||||
}
|
||||
|
||||
& $NssmPath stop $ServiceName | Out-Null
|
||||
& $NssmPath remove $ServiceName confirm | Out-Null
|
||||
Write-Output "Servicio $ServiceName eliminado."
|
||||
Reference in New Issue
Block a user