电光石火-穿越时空电光石火-穿越时空


获取局域网内所有用户和IP

@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 运行即可

 

本博客所有文章如无特别注明均为原创。作者:似水的流年
版权所有:《电光石火-穿越时空》 => 获取局域网内所有用户和IP
本文地址:http://www.ilkhome.cn/index.php/archives/42/
欢迎转载!复制或转载请以超链接形式注明,文章为 似水的流年 原创,并注明原文地址 获取局域网内所有用户和IP,谢谢。

评论