Hello!
If someone could explain the parts of this batch file to me I would appreciate it greatly. I use it every morning when I get in the office to test connectivity of important servers.
I understand what the purpose is, just not how it works, as in what each line does.
Thanks in advance!
---BEGIN CODE---
@echo off
set fnm=C:\Users\xxxxxxx\Desktop\PingBatchFile\shortList.txt
set lnm=C:\Users\xxxxxxx\Desktop\PingBatchFile\pingOutcome.txt
if exist %fnm% goto Label1
echo.
echo Cannot find %fnm%
echo.
Pause
goto :eof
:Label1
echo PingTest STARTED on %date% at %time% > %lnm%
echo ================================================= >> %lnm%
echo.
for /f %%i in (%fnm%) do call :Sub %%i
echo.
echo ================================================= >> %lnm%
echo PingTest ENDED on %date% at %time% >> %lnm%
echo ... now exiting
goto :eof
:Sub
echo Testing %1
set state=alive
ping -n 1 %1
if errorlevel 1 set state=dead
echo %1 is %state% >> %lnm%
---END CODE---
If someone could explain the parts of this batch file to me I would appreciate it greatly. I use it every morning when I get in the office to test connectivity of important servers.
I understand what the purpose is, just not how it works, as in what each line does.
Thanks in advance!
---BEGIN CODE---
@echo off
set fnm=C:\Users\xxxxxxx\Desktop\PingBatchFile\shortList.txt
set lnm=C:\Users\xxxxxxx\Desktop\PingBatchFile\pingOutcome.txt
if exist %fnm% goto Label1
echo.
echo Cannot find %fnm%
echo.
Pause
goto :eof
:Label1
echo PingTest STARTED on %date% at %time% > %lnm%
echo ================================================= >> %lnm%
echo.
for /f %%i in (%fnm%) do call :Sub %%i
echo.
echo ================================================= >> %lnm%
echo PingTest ENDED on %date% at %time% >> %lnm%
echo ... now exiting
goto :eof
:Sub
echo Testing %1
set state=alive
ping -n 1 %1
if errorlevel 1 set state=dead
echo %1 is %state% >> %lnm%
---END CODE---