标题: [网络连接] 批处理或vbs如何得到通过adsl拨号自动获取的ip并记录到txt文本里 [打印本页]
作者: googlegg 时间: 2016-10-9 10:17 标题: 批处理或vbs如何得到通过adsl拨号自动获取的ip并记录到txt文本里
本帖最后由 googlegg 于 2016-10-9 11:01 编辑
用txt文件保存每次adsl拨号得到的外网ip,按ip地址顺序排列,每行一个,如果重复的就覆盖(或不写入)。
打算放到开机启动里,请各位大神赐教!谢谢!
作者: pcl_test 时间: 2016-10-9 12:18
- (
- ipconfig
- wmic nicconfig where "IPEnabled=true" get *|more
- wmic nic where "NetEnabled=true" get *|more
- )>result.txt&pause
复制代码
把生成的result.txt文件打包上传看看
作者: googlegg 时间: 2016-10-10 09:13
本帖最后由 googlegg 于 2016-10-10 09:25 编辑
回复 2# pcl_test
看不懂哦,这是批处理还是vbs?有没有完整的?
作者: codegay 时间: 2016-10-10 09:28
哈哈这种几年的用户。给了代码都不知道是什么的。
作者: googlegg 时间: 2016-10-10 09:45
回复 4# codegay
所以我叫你们大神啊,我水平和你一样我就不叫了
作者: pcl_test 时间: 2016-10-10 21:11
回复 3# googlegg
用bat和vbs两种格式保存运行不就知道了
作者: pcl_test 时间: 2016-10-12 17:14
- @echo off
- rem 猜的。win7以上系统运行
- set "file=ip记录.txt"
- if not exist "%file%" cd.>"%file%"
- for /f %%a in ('powershell -c "([System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()|?{$_.NetworkInterfaceType -eq 'Ppp'}).GetIPProperties().UnicastAddresses[0].Address.ToString()" 2^>nul') do set "ip=%%a"
- if defined ip (
- >nul findstr "^%ip:.=\.%$" "%file%"||powershell -c "(,'%ip%')+(gc '%file%')|sort {$a=$_.split('.');'{0:d3}{1:d3}{2:d3}{3:d3}' -f [int]$a[0],[int]$a[1],[int]$a[2],[int]$a[3]}|out-file '%file%' -encoding default" 2>nul
- )
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |