service status of hostnames from a text file -
i have following code starts service called uvnc_service on hostnames have in text file called find.txt (see below). want add sort of check test if service running on if - nothing , output message screen saying running or if not running on 1 of hosts in find.txt file - start service , output/append hostname file.
can me please?
thanks
find.txt...
pc1 pc2 pc3
...
set service = uvnc_service /f %%a in (c:\temp\find.txt) sc \\%%a start %service% && >> out.txt echo %%a
you can use service control query machine , see status of service ie running
try this
set service = uvnc_service /f %%a in (c:\find.txt) call :servicecheck %%a :servicecheck sc \\%1 query %service% | find "running" if %errorlevel% == 0 goto startservice %1 goto end :startservice sc \\%1 start %service% && >> out.txt echo %1 :end
i cant test on machine , haven't done batch in while might not perfect
Comments
Post a Comment