Batch File Help - TechRepublic
Question
February 28, 2013 at 12:20 AM
jakenguard

Batch File Help

by jakenguard . Updated 13 years, 3 months ago

The script below pings computers what i would like to do is add to the script. If the computer pings i want to copy a folder from a shared drive to the computers C:\ Now i have an idea what i need to add i’m just not 100% sure of what i need to add and where I need to add it.

@echo off
set fnm=c:\Script\Pinger\computers.txt
set lnm=c:\Script\Pinger\Results.txt

if exist %fnm% goto Label1

echo.
echo Cannot find %fnm%
echo.
Pause
goto :eof

:Label1
echo Maintance Pinging STARTED on %date% at %time% > %lnm%
echo ================================================= >> %lnm%
echo.
for /f %%i in (%fnm%) do call :Sub %%i
echo.
echo ================================================= >> %lnm%
echo Maintance ENDED on %date% at %time% >> %lnm%
echo … now exiting
goto :eof

:Sub
echo Testing %1
set state=Pinging.
ping -n 1 %1
if errorlevel 1 set state=Not Pinging.
echo %1 is %state% >> %lnm%

This discussion is locked

All Comments