En hurtig nettester

@Echo OFF
set /p router=Routerip?:
set counter=1
:Loop
Set GoogleDown=
Set RouterDown=
Set HostDown=
:: PING -n 1 -l 1 www.google.dk -4 >Google.ping
:: PING -n 1 -l 1 %Router% -4 >%Router%.ping
:: PING -n 1 -l 1 %Computername% -4 >%Computername%.ping

::Internet connection test
PING -n 1 -l 1 www.google.dk |find /i “Request timed out”
if %Errorlevel%==0 set Googledown=Internet
PING -n 1 -l 1 www.google.dk |find /i “Destination host unreachable”
if %Errorlevel%==0 set Googledown=Internet
PING -n 1 -l 1 www.google.dk |find /i “Destination net unreachable”
if %Errorlevel%==0 set Routerdown=Internet
::Router/Switch connection test
PING -n 1 -l 1 %Router% -4 |find /i “Request timed out”
if %Errorlevel%==0 set Routerdown=Router-or-switch
PING -n 1 -l 1 %Router% -4 |find /i “Destination host unreachable”
if %Errorlevel%==0 set Routerdown=Router-or-switch
PING -n 1 -l 1 %Router% -4 |find /i “Destination net unreachable”
if %Errorlevel%==0 set Routerdown=Router-or-switch
::Lan connection test
ipconfig |find /i “%Router%”
if %Errorlevel%==1 set HostDown=Lan-Connection
if [%Googledown%]==[Internet] echo %Date%;%Time%;%GoogleDown% >> Result.csv
if [%Routerdown%]==[Router-or-switch] echo %Date%;%Time%;%RouterDown% >> Result.csv
if [%HostDown%]==[Lan-Connection] echo %Date%;%Time%;%HostDown% >> Result.csv
CLS
Echo Running … (%counter% – Passes) &set /a Counter=%counter%+1
Timeout 1 >Nul
Goto Loop

Gem som net_test.cmd

Comments are closed.