Thursday, 21 August 2014

CMD - stop / delete service on remoe machine in txt file

@echo off

set LISTFILE=clients.txt

for /f %%a in (%LISTFILE%) do (

    echo.
    echo --------------------------------
    echo.
    echo %%a
    ping -n 1 %%a | find "TTL="
        if not errorlevel 1 (
            echo.
                sc.exe \\%%a stop psexesvc
                sc.exe \\%%a delete psexesvc
            )
        if errorlevel 1 (
            echo %%a unavailable
            )
    )
pause

No comments:

Post a Comment