标题: 关于ipconfig如何只显示内网IP疑问
[打印本页]
作者: heicai
时间: 2007-2-6 05:30
标题: 关于ipconfig如何只显示内网IP疑问
[color=Blue]@echo off
for /f "tokens=15" %%i in ('ipconfig ^| find /i "ip address"') do set ip=%%i
echo %ip%
pause[/color]
这句命令我显示为
61.175.131.10
请按任意键继续. . .
明明我还有个IP是192.168.0.1。假如我想只显示自己内网192.168.0.1(或172.16.0.1)的IP,该怎么改??
作者: heicai
时间: 2007-2-6 05:33
Windows IP Configuration
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.0.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Ethernet adapter 无线网络连接:
Media State . . . . . . . . . . . : Media disconnected
PPP adapter 宽带连接:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 61.175.131.10
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 61.175.131.210
我想指定输出的是带数字172.16.*.* 或192.168.*.*的那种内网地址。可貌似显示效果往往是取最后一个IP ADDRESS的来输出。有什么办法
作者: everest79
时间: 2007-2-6 08:16
for /f "tokens=15" %%i in ('ipconfig ^| find /i "ip address"') do call ipset %%i
set ip
pause
:ipset
set /a st+=1
set ip%st%=%%i
goto :eof
作者: heicai
时间: 2007-2-6 08:50
谢谢你的解答。可是我不明白该如何补充,麻烦你能写全吗?
作者: anqing
时间: 2007-2-6 10:09
@echo off
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "ip address"') do (
set ip=%%a&& goto :gof
)
:gof
echo %ip%
pause
试试看!
作者: heicai
时间: 2007-2-6 10:10
太感谢楼上的朋友了!!!果然有效!
你这代码哪句是控制输出内网IP的???能指点一下吗
另外我想让变量%IP%为192.168.0.
因为最后位我想递增
[
Last edited by heicai on 2007-2-5 at 09:38 PM ]
作者: anqing
时间: 2007-2-6 10:37
set ip=%%a&& goto :gof
这句呀?
&& ,意思是前面的命令执行成功之后才执行后面的命令。
就是取第一个ip成功后,跳出for,到:gof
作者: heicai
时间: 2007-2-6 10:47
@echo off
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "ip address"') do (set ip=%%a&&goto :gof)
:gof
for /f "tokens=1,2,3 delims=." %%b in ("%ip%") do echo %%b.%%c.%%d
pause
试了下这代码,显示结果为
192.168.0
请按任意键继续. . .
前面有个空格,如何避免??
[
Last edited by heicai on 2007-2-5 at 10:04 PM ]
作者: heicai
时间: 2007-2-6 11:14
晕。我想判断对方是哪类的内网IP地址,然后自动进行IPC循环复制文件。
咋就这么难呢??
作者: heicai
时间: 2007-2-6 11:27
net use \\%IP\ipc$ "123" /user:"administrator" && copy test.exe \\%IP\admin$ && start test.exe
%IP由网段而定,有可能172.16开头,有可能192.168开头.这问题已经解决了。
现在要%IP让它累加。
谁能帮我完工
作者: anqing
时间: 2007-2-6 12:15
Quote: |
Originally posted by heicai at 2007-2-6 10:47:
@echo off
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "ip address"') do (set ip=%%a&&goto :gof)
:gof
for /f "tokens=1,2,3 delims=." %%b in (&quo ... |
|
@echo off
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "ip address"') do (
set ip=%%a&& goto :gof
)
:gof
set "ip=%ip: =%"
echo %ip%
pause
去掉192前面的空格
作者: ding520
时间: 2007-2-17 03:44
...........