本帖最后由 ygqiang 于 2015-7-16 21:01 编辑
[已解决]- @echo off
- setlocal enabledelayedexpansion
- set "aa= "
- cd.>在线ip-计算机名.txt
- for /f "tokens=15 delims= " %%i in ('ipconfig ^| find /i "IP Address"') do (
- set fsip=%%i
- )
- echo %fsip%
-
-
- for /f "tokens=1,2,3 delims=." %%i in ("%fsip%") do (
- set a=%%i.%%j.%%k
- )
-
-
- set Gateway=%a%.1
-
-
- del /f /q 在线ip-计算机名.txt >nul 2>nul
-
-
- for /l %%m in (1,1,254) do (
- ping.exe %a%.%%m -n 1 -w 300 >nul&&Call :getname %a%.%%m
- )
-
- echo "查询结束"
- exit
-
-
- :getname
- set iip=%1
- set nname=
- for /f "delims=" %%i in ('nbtstat -a !iip! ^| find /i "<00> UNIQUE"') do (
- echo %%i
- set tii=%%i
- for /f "tokens=1 delims=< " %%j in ("!tii!") do echo !iip!!aa!%%j>>在线ip-计算机名.txt
- goto :aa
- )
- for /f "delims=" %%j in ('nbtstat -a !iip! ^| find /i "Host not found"') do (
- echo %%j
- echo !iip!>>在线ip-计算机名.txt
- )
- :aa
复制代码 在线ip-计算机名-自动扫描.bat,这个代码帮忙修改下。。。谢谢。。
这个bat代码,生成的txt文件内容如下:- 192.168.8.11 CB1
- 192.168.8.12 CB2
- 192.168.8.13 CB3
- 192.168.8.14 CB4
- 192.168.8.15 CB5
- 192.168.8.16 CB6
复制代码 如何修改下bat代码,生成如下txt的内容呢?- CB1 192.168.8.11
- CB2 192.168.8.12
- CB3 192.168.8.13
- CB4 192.168.8.14
- CB5 192.168.8.15
- CB6 192.168.8.16
复制代码
|