Difference between revisions of "Sc.exe"

From UVOO Tech Wiki
Jump to navigation Jump to search
 
Line 12: Line 12:
 
```
 
```
 
SC Failure <servicename> actions= restart/<x delay in milliseconds>/restart/<y delay in milliseconds>/restart/<z delay in milliseconds>// reset= <number of seconds until failure count is reset>
 
SC Failure <servicename> actions= restart/<x delay in milliseconds>/restart/<y delay in milliseconds>/restart/<z delay in milliseconds>// reset= <number of seconds until failure count is reset>
 +
```
 +
 +
```
 +
foreach($line in Get-Content .\hosts.txt) {
 +
    write-output $line
 +
    Invoke-Command -ComputerName "$line" -ScriptBlock { sc.exe failure "my service" reset=36000 actions=restart/90000 }
 +
}
 
```
 
```

Latest revision as of 15:31, 10 May 2022

Set service to restart automatically. Set-Service does not do this

$sumohost = "myhostname"; Invoke-Command -ComputerName $sumohost -ScriptBlock { sc.exe failure sumo-collector reset=3600 actions= restart/30000 }

sc.exe Qfailure "zabbix agent 2"
sc.exe failure "zabbix agent 2" reset=3600 actions= restart/30000
SC failure YOUR_SERVICE_NAME reset= 0 actions= restart/0/restart/0/restart/0
SC Failure <servicename> actions= restart/<x delay in milliseconds>/restart/<y delay in milliseconds>/restart/<z delay in milliseconds>// reset= <number of seconds until failure count is reset>
foreach($line in Get-Content .\hosts.txt) {
    write-output $line
    Invoke-Command -ComputerName "$line" -ScriptBlock { sc.exe failure "my service" reset=36000 actions=restart/90000 }
}