1.WMIC
wmic nicconfig where Description="WAN (PPP/SLIP) Interface" get ipaddress
在命令行中输入应该就可以看到PPP拨号的IP了。
2.netsh
netsh diag show ip 1
一般来说,netsh显示IP会把PPP拨号的IP显示在前,所以show ip 1应该能够实现目的,同样的,如果用show ip 2则会显示网卡的IP。(若有哪位的IP排列和我的相反请吱一声,我这没条件测试。)
3.ipconfig
@echo off
for /f "tokens=2 delims=:" %%i in ('ipconfig ^|findstr /i "ip address"') do set ip=%%i
echo %ip%
pause
和netsh相反,ipconfig在显示IP的时候会把网卡IP显示在前面,所以只要获得后面的IP就可以得到我们需要的IP。
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.