China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 18:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] How to use batch processing to obtain the IP address of the PPP dial-up connection View 2,163 Replies 10
Original Poster Posted 2006-10-01 10:12 ·  中国 北京 移动
高级用户
★★
Credits 638
Posts 168
Joined 2006-07-14 17:12
20-year member
UID 58572
Gender Female
Status Offline
How to use batch processing to obtain the IP address of a PPP dial-up connection?

[ Last edited by HAT on 2008-10-15 at 20:44 ]
Floor 2 Posted 2006-10-01 11:22 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
I don't know what purpose you have for the IP address obtained from the PPP dial-up connection. I searched for relevant discussions with "IP" as the keyword and posted a few search results. The poster can go and have a look:

1、How to set IP address and DNS with BAT file?;
2、How to get the local IP and MAC address in batch processing and then bind them?;
3、Reprint: How to change the IP address at the command line
4、Ask how to write BAT to obtain computer name, workgroup name and IP address
……
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2006-10-01 11:33 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Type IPCONFIG at the DOS prompt and press Enter, and you can see IP addresses and other information similar to the following.

IPCONFIG is the command to view current IP address information



Microsoft Windows XP
(C) Copyright 1985-2001 Microsoft Corp.

C:\WINDOWS>ipconfig

Windows IP Configuration


Ethernet adapter Wireless Intel:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.0.12
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . : 192.168.0.1

Ethernet adapter Local Area Connection:

Media State . . . . . . . . . . . : Media disconnected


Floor 4 Posted 2006-10-01 11:36 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
1. WMIC
wmic nicconfig where Description="WAN (PPP/SLIP) Interface" get ipaddress

You should be able to see the PPP dial-up IP by entering this in the command line.
2. netsh
netsh diag show ip 1

Generally speaking, netsh will display the PPP dial-up IP first when showing the IP, so "show ip 1" should achieve the purpose. Similarly, "show ip 2" will display the IP of the network card. (If anyone's IP arrangement is opposite to mine, please let me know. I don't have conditions to test here.)
3. ipconfig

@echo off
for /f "tokens=2 delims=:" %%i in ('ipconfig ^|findstr /i "ip address"') do set ip=%%i
echo %ip%
pause

Opposite to netsh, ipconfig will display the network card IP first when showing the IP, so just get the subsequent IP to get the IP we need.
Floor 5 Posted 2006-10-01 11:40 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
%appdata%\Microsoft\Network\Connections\Pbk\rasphone.pbk
%systemroot%\System32\Ras
There are very files in these two folders, which can be analyzed with for

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 6 Posted 2006-10-02 10:50 ·  中国 广东 深圳 联通
高级用户
★★
Credits 638
Posts 168
Joined 2006-07-14 17:12
20-year member
UID 58572
Gender Female
Status Offline
Thanks, Moderator 3742668.

But

wmic nicconfig where Description="WAN (PPP/SLIP) Interface" get ipaddress
'wmic' is not recognized as an internal or external command, operable program or batch file.

netsh diag show ip 1
The following command was not found: diag show ip 1.

When selecting the dial-up connection at login, ipconfig displays the IP of the PPP dial-up connection first.

Please give advice!

I have read the posts introduced by Moderator namejm, but they are not very helpful.
Floor 7 Posted 2006-10-02 10:55 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
20-year member
UID 58987
From 湖南.娄底
Status Offline
The building owner posts the display of ipconfig for everyone to see.
Floor 8 Posted 2006-10-02 11:09 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
Could it be that you installed the Home edition of XP? The Home edition of XP doesn't have the WMI component, so there's no WMIC either. Maybe the unsuccessful execution of the netsh command is related to it.
My test environment is Professional Edition SP2. Please state your system environment.
Floor 9 Posted 2006-10-03 09:06 ·  中国 广东 深圳 联通
高级用户
★★
Credits 638
Posts 168
Joined 2006-07-14 17:12
20-year member
UID 58572
Gender Female
Status Offline
Floor 10 Posted 2006-10-07 03:18 ·  中国 江苏 镇江 电信
中级用户
★★
Credits 219
Posts 82
Joined 2005-10-29 10:56
20-year member
UID 44240
Status Offline
My environment: 3 network cards, 2 PPPOE connections, that is, 5 connections. The part of the script I made for a friend to do ADSL dual-line (simultaneously surfing with Netcom and Telecom):

@echo off
ipconfig/all >>iptable.txt
for /f "skip=48 tokens=2 delims=:" %%i in (iptable.txt) do echo %%i >>2.txt
set /p ip=<2.txt
echo %ip%
pause
del *.txt >nul

If you want to use it, you need to modify it according to your actual situation. You only need to change the value of skip=48 to the line number where the IP is in iptable.txt.

[ Last edited by jastyg on 2006-10-7 at 03:21 ]
www.jastyg.com
www.efengchi.com
Floor 11 Posted 2008-10-15 20:35 ·  中国 北京 鹏博士长城宽带
初级用户
Credits 26
Posts 17
Joined 2008-10-06 20:28
17-year member
UID 127584
Gender Male
Status Offline
Forum Jump: