I'll give you two options:
1, with ping command;
2. Use the net view command.
Use these two commands combined with a batch program to achieve your goal!
These two bat is what I wrote before, you can change to become you use to get! Oh!
1. Ping scheme (manually enter start IP and end IP):
Off
Title Scan Online IP
:: MODE con:cols=60 lines=18
Color 0a
:: Decoration.
: Kaishi
Cls
FOR/L%%i in (1,1,4) do echo.
echo Enter start IP address and end IP address and enter, scan complete
After Echo will generate a TXT file in this program directory, the file is recorded in the
Echo online and not on the line of the host.
Echo.
set/p qishi= Start IP:
set/p jieshu= terminating IP:
IF ERRORLEVEL 1 echo wrong IP address format! && Pause && Goto Kaishi
Echo.
:: Gets the value of two variables from the keyboard.
for/f "Tokens=1-4 delims=."%%a in ("%qishi%") Do (
If%%a LSS 0 goto Error
If%%a GTR 255 goto Error
If%%b LSS 0 goto Error
If%%b GTR 255 goto Error
If%%c LSS 0 goto Error
If%%c GTR 255 goto Error
If%%d LSS 0 goto Error
If%%d GTR 255 goto Error
Set V1=%%a
Set V2=%%b
Set v3=%%c
Set v4=%%d
)
:: Divide four segments of the starting IP and assign values to determine if the IP is correct.
for/f "Tokens=1-4 delims=."%%a in ("%jieshu%") Do (
If%%a LSS 0 goto Error
If%%a GTR 255 goto Error
If%%b LSS 0 goto Error
If%%b GTR 255 goto Error
If%%c LSS 0 goto Error
If%%c GTR 255 goto Error
If%%d LSS 0 goto Error
If%%d GTR 255 goto Error
Set V5=%%a
Set V6=%%b
Set v7=%%c
Set v8=%%d
)
:: Divide four segments terminating IP and assign a value to determine if the IP is correct.
IF%v5% LSS%v1% echo Error: The terminating IP cannot be less than the start IP. & Pause & Goto Kaishi
:: Determine the correctness of terminating IP and starting IP.
Echo is scanning ...
IF%v4% LEQ%v8% set zengzhi_1=1
IF%v4% GEQ%v8% set Zengzhi_1=-1
IF%v3% LEQ%v7% set zengzhi_2=1
IF%v3% GEQ%v7% set Zengzhi_2=-1
IF%v2% LEQ%v6% set zengzhi_3=1
IF%v2% GEQ%v6% set Zengzhi_3=-1
FOR/L%%d in (%v1%,1,%v5%) do (
FOR/L%%c in (%v2%,%zengzhi_3%,%v6%) do (
FOR/L%%b in (%v3%,%zengzhi_2%,%v7%) do (
FOR/L%%a in (%v4%,%zengzhi_1%,%v8%) do (
ping/n 1%%d.%%c.%%b.%%a >nul && echo%%d.%%c.%%b.%%a power on && echo%%d.%%c.%%b.%%a>> online host. txt | | echo%%d.%%c.%%b.%%a shutdown && echo%%d.%%c.%%b.%%a >> not online host. txt
)
)
)
)
FOR/L%%i in (1,1,5) do echo.
Echo☆ Report ☆
IF EXIST Online host. TXT (
for/f "Tokens=3 delims="%%c in (' find/c online host. txt "" ') do set zx=%%c
) ELSE (
Set zx=0
)
IF EXIST not online host. TXT (
for/f "Tokens=3 delims="%%c in (' Find/c not online host. txt "" ') do set bzx=%%c
) ELSE (
Set bzx=0
)
set/a zgjsj=%zx%+%bzx%
echo%date%%time%>☆ report ☆.txt
Echo swept the%zgjsj% computer! & Echo swept the%zgjsj% computer!>>☆ report ☆.txt
ECHO has%zx% computer online! & Echo has%zx% pc online!>>☆ report ☆.txt
ECHO has%bzx% computer not on the line! & Echo has%bzx% computer not in line!>>☆ report ☆.txt
echo automatically exits after 10 seconds ... & Ping 127.1-n >nul & Exit
: Error
echo Error IP address!
Pause
Goto Kaishi
2. NET view scheme (fully automatic):
Off
Title Shared scan: IPC speaking ...
MODE con:cols=80 lines=22
Color 0a
Echo.
All computers in the Echo workgroup:
for/f "eol=-delims=\"%%c in (' Net View ') do (
for/f "Eol="%%i in (' echo%%c ') does (
For/f "eol= Life"%%i in (' echo%%c ') does (
Echo%%i
Echo%%i>> all online host. txt
Echo%%i>>pcname.txt
Echo%%i >>pcname2.txt
)
)
)
:: Echo parses the IP address of its computer ...
:: for/f "delims="%%h in (pcname.txt) do
:: for/f "tokens=3 delims="%%j in (' ping%%h-n 1 ') do echo%%j
::)
Echo.
echo Scan shared files ...
for/f "delims="%%c in (pcname.txt) does (
NET view \%%c >nul 2>nul && echo%%c>> have shared. txt && echo%%c shared files:>> shared files 2.txt && echo ==============================================>> shared files 2.txt && net view \%%c>> shared files 2.txt && echo .>> shared files 2.txt && echo .>> shared files 2.txt && echo%%c Shared | | Echo%%c No share
)
:: Remove extra text in net VIEW command results
For/f "eol= at delims="%%c in (shared file 2.txt) do (
for/f "eol=-delims="%%i in (' Echo-%%c ') do (
for/f "Eol= delims="%%c in (' echo%%i ') do (
echo%%c>> shared files. txt
)
)
)
Echo.
echo Scan can IPC hug regret ...
for/f "delims="%%i in (pcname.txt) does (
NET use \%%IIPC "/user:" ">nul 2>nul && echo%%i>>ipc Ying tan φ regret. txt && net use \%%i/del>nul & amp;& Echo%%i IPC Sun!| | echo%%i IPC mail it!
)
Echo.
Echo.
Echo.
Echo☆ Report ☆
IF EXIST Pcname2.txt (
for/f "Tokens=3 delims="%%c in (' find/c pcname2.txt ' "') does echo current workgroup has%%c computer!
) ELSE (
Echo currently has 0 computers in the workgroup!
)
IF EXIST has shared. txt (
for/f "Tokens=3 delims="%%c in (' find/c has shared. txt "" ') do echo current workgroup has%%c computer with shared files! & del has shared. txt
) ELSE (
echo 0 computers in the current workgroup have shared files
)
IF EXIST IPC mirrored φ regret. TXT (
for/f "Tokens=3 delims="%%c in (' Find/c IPC Sun φ (regret. txt "" ') do echo current workgroup has%%c computer IPC Ji Sun!
) ELSE (
Echo currently has 0 computers in the workgroup IPC JI Sun!
)
Del Pcname.txt>nul
Del Pcname2.txt>nul
del shared files 2.txt>nul
echo automatically exits after 10 seconds ... & Ping 127.1-n >nul & Exit
Write the code for your situation:
Off
Echo is scanning ...
for/f "delims="%%c in (d:esthostname.txt) do ping%%c/n 1 >nul && echo%%c boot up! && echo%%c>>d:est boot host. txt| | echo%%c off! && echo%%c>>d:est shutdown host. txt
echo Scan is complete!
Pause
Batch processing to detect whether the LAN computer is powered on (reproduced)