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

http://ss64.com/nt/sc.html

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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -