Supportnet / Forum / BS-Sonstige
batch IP Scanner
Frage
hi,
weis jemand von euch wie man den IP scanner so umformt, dass er bis 255.255.255.255 durchläuft??
@echo off
cls
set ip1=192
set /p ip1=XXX.xxx.xxx.xxx(Standart:192):
set ip2=168
set /p ip2=xxx.XXX.xxx.xxx(Standart:168):
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx(Standart:0):
set ip4=1
set /p ip4=xxx.xxx.xxx.XXX(Standart:1):
cls
echo.
echo Clients in diesem Lan:
echo.
:start
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
if /i %ip4% NEQ 256 set /a ip4=%ip4%+1
if /i %ip4% EQU 256 set /a ip3=%ip3%+1
if /i %ip4% EQU 256 set /a ip4=1
if %ip3% NEQ 256 goto start
:ende
echo.
echo Suche abgeschlossen.
pause
Antwort 1 von manei
Hallo,
versuche es mal damit:
if /i %ip4% LSS 255 set /a ip4=%ip4%+1
if /i %ip4% EQU 255 if /i %ip3" LSS 255 set /a ip3=%ip3%+1
if /i %ip4% EQU 255 if /i %ip3" EQU 255 if /i %ip2% LSS 256 set /a ip2=%ip2%+1
if /i %ip4% EQU 255 if /i %ip3" EQU 255 if /i %ip2% EQU 256 if /i %ip1% LSS 256 set /a ip1=%ip1%+1
Das sollte auch mit = und > bzw < klappen.
einfacher sollte es mit Sprungmarken gehen:
set x=1
:start
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
goto x%x%
:x1
if /i %ip4% LSS 255 for %%e in ("set /a" goto:start) do %%e ip4=%ip4%+1
for %%e in (set goto:start) do %%e x=2
:x2
if /i %ip3% LSS 255 for %%e in ("set /a" goto:start) do %%e ip3=%ip3%+1
for %%e in (set goto:start) do %%e x=3
:x3
if /i %ip2% LSS 255 for %%e in ("set /a" goto:start) do %%e ip2=%ip2%+1
for %%e in (set goto:start) do %%e x=4
:x4
if /i %ip1% LSS 255 for %%e in ("set /a" goto:start) do %%e ip1=%ip1%+1
:ende
MfG maneich
versuche es mal damit:
if /i %ip4% LSS 255 set /a ip4=%ip4%+1
if /i %ip4% EQU 255 if /i %ip3" LSS 255 set /a ip3=%ip3%+1
if /i %ip4% EQU 255 if /i %ip3" EQU 255 if /i %ip2% LSS 256 set /a ip2=%ip2%+1
if /i %ip4% EQU 255 if /i %ip3" EQU 255 if /i %ip2% EQU 256 if /i %ip1% LSS 256 set /a ip1=%ip1%+1
Das sollte auch mit = und > bzw < klappen.
einfacher sollte es mit Sprungmarken gehen:
set x=1
:start
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
goto x%x%
:x1
if /i %ip4% LSS 255 for %%e in ("set /a" goto:start) do %%e ip4=%ip4%+1
for %%e in (set goto:start) do %%e x=2
:x2
if /i %ip3% LSS 255 for %%e in ("set /a" goto:start) do %%e ip3=%ip3%+1
for %%e in (set goto:start) do %%e x=3
:x3
if /i %ip2% LSS 255 for %%e in ("set /a" goto:start) do %%e ip2=%ip2%+1
for %%e in (set goto:start) do %%e x=4
:x4
if /i %ip1% LSS 255 for %%e in ("set /a" goto:start) do %%e ip1=%ip1%+1
:ende
MfG maneich
Antwort 2 von rudolph
Hi,
so:
@echo off
cls
set ip1=192
set /p ip1=XXX.xxx.xxx.xxx(Standart:192):
set ip2=168
set /p ip2=xxx.XXX.xxx.xxx(Standart:168):
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx(Standart:0):
set ip4=1
set /p ip4=xxx.xxx.xxx.XXX(Standart:1):
cls
echo.
echo Clients in diesem LAN:
echo.
set x=1
:start
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
goto x%x%
:x1
if /i %ip4% LSS 255 for %%e in ("set /a" goto:start) do %%e ip4=%ip4%+1
for %%e in (set goto:start) do %%e x=2
:x2
if /i %ip3% LSS 255 for %%e in ("set /a" goto:start) do %%e ip3=%ip3%+1
for %%e in (set goto:start) do %%e x=3
:x3
if /i %ip2% LSS 255 for %%e in ("set /a" goto:start) do %%e ip2=%ip2%+1
for %%e in (set goto:start) do %%e x=4
:x4
if /i %ip1% LSS 255 for %%e in ("set /a" goto:start) do %%e ip1=%ip1%+1
:ende
echo.
echo Suche abgeschlossen.
pause
geht nicht, da kommt immer "Das System kann den angegebenen Pfad nicht finden."
Was mache ich falsch?
so:
@echo off
cls
set ip1=192
set /p ip1=XXX.xxx.xxx.xxx(Standart:192):
set ip2=168
set /p ip2=xxx.XXX.xxx.xxx(Standart:168):
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx(Standart:0):
set ip4=1
set /p ip4=xxx.xxx.xxx.XXX(Standart:1):
cls
echo.
echo Clients in diesem LAN:
echo.
set x=1
:start
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
goto x%x%
:x1
if /i %ip4% LSS 255 for %%e in ("set /a" goto:start) do %%e ip4=%ip4%+1
for %%e in (set goto:start) do %%e x=2
:x2
if /i %ip3% LSS 255 for %%e in ("set /a" goto:start) do %%e ip3=%ip3%+1
for %%e in (set goto:start) do %%e x=3
:x3
if /i %ip2% LSS 255 for %%e in ("set /a" goto:start) do %%e ip2=%ip2%+1
for %%e in (set goto:start) do %%e x=4
:x4
if /i %ip1% LSS 255 for %%e in ("set /a" goto:start) do %%e ip1=%ip1%+1
:ende
echo.
echo Suche abgeschlossen.
pause
geht nicht, da kommt immer "Das System kann den angegebenen Pfad nicht finden."
Was mache ich falsch?
Antwort 3 von manei
Hallo,
sicher liegt der Fehler nicht bei Dir, doch leider habe ich hier momentan kein W2K/XP zum testen zur Verfügung. Da ich sowohl mit W2K/XP als auch mit WinME arbeite, was bezüglich der Batchbefehle und den Möglichkeiten sehr unterschiedlich ist, kommst da schon mal einiges durcheinander
Ich habe hier jeweils nur für die erste Abfrage noch 2 Möglichkeiten dargestellt. Du kannst das ja zunächst mal in einer test.bat testen, dazu mußt du nur noch vor dieser Zeile :start und vor .start ip4 definieren. Also z.B.
set ip4=0
:start
if /i %ip4% LSS 255 for /f %%e in ('set /a ip4=%ip4%+1' goto:start) do %%e
oder genau so mit
if /i %ip4% LSS 255 for /f %%e in ('set /a ip4=%ip4%+1') do %%e & goto start
Die Zeile die läuft dann auch für die Zeilen mit ip3-ip1 anpassen.
Ich glaube es gibt aber auch noch eine einfachere Lösung mit
@echo off
cls
set ip1=192
set /p ip1=XXX.xxx.xxx.xxx(Standart:192):
set ip2=168
set /p ip2=xxx.XXX.xxx.xxx(Standart:168):
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx(Standart:0):
set ip4=1
set /p ip4=xxx.xxx.xxx.XXX(Standart:1):
cls
echo.
echo Clients in diesem LAN:
echo.
set x=4
:start
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
if /i %ip%x%% LSS 255 goto subrout
if %x%==4 for %%e in (set goto:start) do %%e x=3
if %x%==3 for %%e in (set goto:start) do %%e x=2
if %x%==2 for %%e in (set goto:start) do %%e x=1
goto end
:subrout
set /a ip%x%+=1
goto start
:ende
echo.
echo Suche abgeschlossen.
pause
MfG maneich
sicher liegt der Fehler nicht bei Dir, doch leider habe ich hier momentan kein W2K/XP zum testen zur Verfügung. Da ich sowohl mit W2K/XP als auch mit WinME arbeite, was bezüglich der Batchbefehle und den Möglichkeiten sehr unterschiedlich ist, kommst da schon mal einiges durcheinander
Ich habe hier jeweils nur für die erste Abfrage noch 2 Möglichkeiten dargestellt. Du kannst das ja zunächst mal in einer test.bat testen, dazu mußt du nur noch vor dieser Zeile :start und vor .start ip4 definieren. Also z.B.
set ip4=0
:start
if /i %ip4% LSS 255 for /f %%e in ('set /a ip4=%ip4%+1' goto:start) do %%e
oder genau so mit
if /i %ip4% LSS 255 for /f %%e in ('set /a ip4=%ip4%+1') do %%e & goto start
Die Zeile die läuft dann auch für die Zeilen mit ip3-ip1 anpassen.
Ich glaube es gibt aber auch noch eine einfachere Lösung mit
@echo off
cls
set ip1=192
set /p ip1=XXX.xxx.xxx.xxx(Standart:192):
set ip2=168
set /p ip2=xxx.XXX.xxx.xxx(Standart:168):
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx(Standart:0):
set ip4=1
set /p ip4=xxx.xxx.xxx.XXX(Standart:1):
cls
echo.
echo Clients in diesem LAN:
echo.
set x=4
:start
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
if /i %ip%x%% LSS 255 goto subrout
if %x%==4 for %%e in (set goto:start) do %%e x=3
if %x%==3 for %%e in (set goto:start) do %%e x=2
if %x%==2 for %%e in (set goto:start) do %%e x=1
goto end
:subrout
set /a ip%x%+=1
goto start
:ende
echo.
echo Suche abgeschlossen.
pause
MfG maneich
Antwort 4 von rudolph
hi!
dieser code (selbsgemacht) funktioniert eigentlich, doch beim ergebniss macht er für jede gsescannte IP ne zeile, egal ob sie erreichtbar ist oder nicht...
@echo off
set ip1=0
set /p ip1=XXX.xxx.xxx.xxx:
set ip2=0
set /p ip2=xxx.XXX.xxx.xxx:
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx:
set ip4=0
set /p ip4=xxx.xxx.xxx.XXX:
echo.
echo Gefundene IP's:
echo.
:start
echo.
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
if not %ip4%==256 set /a ip4=%ip4%+1
if %ip4%==256 set /a ip3=%ip3%+1
if %ip4%==256 set ip4=1
if %ip3%==256 set /a ip2=%ip2%+1
if %ip3%==256 set ip3=1
if %ip3%==256 goto start
if %ip2%==256 set /a ip1=%ip1%+1
if %ip2%==256 set ip2=1
if %ip2%==256 goto start
if %ip1%==256 goto ende
goto start
:ende
echo Alles gescannt!
pause
die ausgabe siehtt so aus
Gefundene IP's:
192.168.0.100
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
192.168.0.111
###=garnix (leere zeile)
wei kann ich das machhen, dass wenn die IP nicht erreichbar ist auch wirklich garnix ausgegeben wirs?Es wird die IP zar nicht als erreichbar angezeigt, aber die leeren zeilen stören...
ich hoffe ihr kapiert das jetzt..
danke ..
dieser code (selbsgemacht) funktioniert eigentlich, doch beim ergebniss macht er für jede gsescannte IP ne zeile, egal ob sie erreichtbar ist oder nicht...
@echo off
set ip1=0
set /p ip1=XXX.xxx.xxx.xxx:
set ip2=0
set /p ip2=xxx.XXX.xxx.xxx:
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx:
set ip4=0
set /p ip4=xxx.xxx.xxx.XXX:
echo.
echo Gefundene IP's:
echo.
:start
echo.
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
if not %ip4%==256 set /a ip4=%ip4%+1
if %ip4%==256 set /a ip3=%ip3%+1
if %ip4%==256 set ip4=1
if %ip3%==256 set /a ip2=%ip2%+1
if %ip3%==256 set ip3=1
if %ip3%==256 goto start
if %ip2%==256 set /a ip1=%ip1%+1
if %ip2%==256 set ip2=1
if %ip2%==256 goto start
if %ip1%==256 goto ende
goto start
:ende
echo Alles gescannt!
pause
die ausgabe siehtt so aus
Gefundene IP's:
192.168.0.100
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
##############<--- leere Zeilen aber ohne text
192.168.0.111
###=garnix (leere zeile)
wei kann ich das machhen, dass wenn die IP nicht erreichbar ist auch wirklich garnix ausgegeben wirs?Es wird die IP zar nicht als erreichbar angezeigt, aber die leeren zeilen stören...
ich hoffe ihr kapiert das jetzt..
danke ..
Antwort 5 von rudolph
Hi!
:D hab den fehler selber gefunden..
echo. macht da ja nach jedem durchlauf ne leere zeile...
Also alles im Butter!!!
:D hab den fehler selber gefunden..
echo. macht da ja nach jedem durchlauf ne leere zeile...
@echo off
set ip1=0
set /p ip1=XXX.xxx.xxx.xxx:
set ip2=0
set /p ip2=xxx.XXX.xxx.xxx:
set ip3=0
set /p ip3=xxx.xxx.XXX.xxx:
set ip4=0
set /p ip4=xxx.xxx.xxx.XXX:
echo.
echo Gefundene IP's:
echo.
:start
echo.
ping -w 25 -n 1 %ip1%.%ip2%.%ip3%.%ip4% | FIND "TTL" >nul
if not errorlevel 1 echo %ip1%.%ip2%.%ip3%.%ip4%
if not %ip4%==256 set /a ip4=%ip4%+1
if %ip4%==256 set /a ip3=%ip3%+1
if %ip4%==256 set ip4=1
if %ip3%==256 set /a ip2=%ip2%+1
if %ip3%==256 set ip3=1
if %ip3%==256 goto start
if %ip2%==256 set /a ip1=%ip1%+1
if %ip2%==256 set ip2=1
if %ip2%==256 goto start
if %ip1%==256 goto ende
goto start
:ende
echo Alles gescannt!
pause
Also alles im Butter!!!
Antwort 6 von DL9YFE
Hallo,
sehr interessant und genau so etwas ähnliches habe ich auch gesucht.
Problem: unter XP funktioniert super;
unter 98 "Syntaxfehler" bei if /i NEQ ; set /a ; ......
kann mir da jemand weiterhelfen?
vy 73 Andreas
sehr interessant und genau so etwas ähnliches habe ich auch gesucht.
Problem: unter XP funktioniert super;
unter 98 "Syntaxfehler" bei if /i NEQ ; set /a ; ......
kann mir da jemand weiterhelfen?
vy 73 Andreas

