Harden Windows service supervision
This commit is contained in:
+9
-2
@@ -27,12 +27,16 @@ try {
|
||||
$StartupSettings = New-ScheduledTaskSettingsSet `
|
||||
-StartWhenAvailable `
|
||||
-MultipleInstances IgnoreNew `
|
||||
-ExecutionTimeLimit ([TimeSpan]::Zero) `
|
||||
-DontStopIfGoingOnBatteries `
|
||||
-RestartCount 3 `
|
||||
-RestartInterval (New-TimeSpan -Minutes 1)
|
||||
} catch {
|
||||
$StartupSettings = New-ScheduledTaskSettingsSet `
|
||||
-StartWhenAvailable `
|
||||
-MultipleInstances IgnoreNew
|
||||
-MultipleInstances IgnoreNew `
|
||||
-ExecutionTimeLimit ([TimeSpan]::Zero) `
|
||||
-DontStopIfGoingOnBatteries
|
||||
}
|
||||
|
||||
Register-ScheduledTask `
|
||||
@@ -51,7 +55,9 @@ $WatchdogTrigger = New-ScheduledTaskTrigger `
|
||||
-RepetitionDuration (New-TimeSpan -Days 3650)
|
||||
$WatchdogSettings = New-ScheduledTaskSettingsSet `
|
||||
-StartWhenAvailable `
|
||||
-MultipleInstances IgnoreNew
|
||||
-MultipleInstances IgnoreNew `
|
||||
-ExecutionTimeLimit (New-TimeSpan -Minutes 2) `
|
||||
-DontStopIfGoingOnBatteries
|
||||
|
||||
Register-ScheduledTask `
|
||||
-TaskName $WatchdogTaskName `
|
||||
@@ -66,6 +72,7 @@ Write-Host "[OK] Scheduled task `"$WatchdogTaskName`" has been created."
|
||||
Write-Host "[OK] Startup runner: `"$RunnerBat`""
|
||||
Write-Host "[OK] Watchdog: `"$WatchdogBat`""
|
||||
Write-Host "[OK] Log file: `"$LogFile`""
|
||||
Write-Host "[OK] Startup task execution limit: disabled"
|
||||
Write-Host ""
|
||||
Write-Host "Verify:"
|
||||
Write-Host "schtasks /Query /TN `"$TaskName`" /V /FO LIST"
|
||||
|
||||
Reference in New Issue
Block a user