Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Batch script to check a service is running on remote servers

$
0
0

Hey Guys

I have the bare bones of a script below . What i want it to do is

(1) Check from a list called servers.txt

(2) Check is a particular service is running

(3) If it's not then start it

(4) Echo the results to a file called results.txt

net start | find "servicename" > nul 2>&1
if not .%errorlevel%.==.0. goto startservice
goto skip


:startservice
net start "servicename"
echo service restarts @ %date% %time% >> C:\results.txt


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>