代码语言:js复制
@echo off&setlocal enabledelayedexpansion
title 获取局域网内所有用户
echo winxp 英文版系统可能会出现错误 用于支持net view 命令的计算机
echo.
echo 用于没有开防火墙的计算机!
net view>%temp%users.txt
find /c " " %temp%users.txt>%temp%number.txt
for /f "tokens=3 delims=:" %%i in (%temp%number.txt) do set number=%%i
echo.
echo.
echo 总共有%number%台电脑
echo.
echo --------------------------------------------------
nbtstat -s |find "IP">%temp%localip.txt
for /f "tokens=4" %%i in (%temp%localip.txt) do set IP=%%i
echo 本机为:
hostname
echo IP为: %IP%
echo --------------------------------------------------
echo.
echo 其他用户有:
echo.
for /f "eol=命 skip=3 tokens=1,2,3 delims= " %%i in (%temp%users.txt) do (echo %%i&ping -n 1 %%i>nul&nbtstat -a %%i|find "MAC">>%temp%mac.txt)
for /f "tokens=4 delims= " %%i in (%temp%mac.txt) do (arp -a |find /i "%%i" >>%temp%ip.txt)
echo -------------------------------------------------
echo.
echo 正在获取用户对应的IP地址...请耐心等待...
echo.
echo.
for /f "tokens=1 delims= " %%i in (%temp%ip.txt) do (ping -a -n 1 %%i>>%temp%user.txt)
type %temp%user.txt|find /i "正在 Ping">>%temp%over.txt
for /f "tokens=3,4 delims= " %%i in (%temp%over.txt) do echo 用户: %%i IP地址: %%j
echo.
echo ok!
del /q %temp%users.txt
del /q %temp%ip.txt
del /q %temp%mac.txt
del /q %temp%user.txt
del /q %temp%over.txt
del /q %temp%number.txt
del /q %temp%localip.txt
pause>nul
exit
::这个应该很简单吧
保存以上代码到 获取局域网内所有用户和IP.bat 运行即可