用注册表更改DNS的代码分享
最进我这里dns老是间歇性掉,很不稳定,广州地区,如果你的dns经常需要更换,试试这个批处理,
论坛很多人发过了更改dns的批处理,但改的过程批处理等待有点缓慢,还有的同志的本地连接有2到n位的,改时很不方便.
批处理内容:
echo off
regedit /s \\\\server\\xx\\xx.reg
cls
\\\\server\\xx\\xx.reg为你的远程路劲.,不要用我的,只需修改红色部分为你的远程路劲,
下面是dns的注册表项,我的是2000,
windows registry editor version 5.00
[hkey_local_machine\\system\\controlset001\\services\\tcpip\\parameters\\interfaces\\{b130bf2a-0bd5-4b4d-b3a9-55a94fc46694}]
"usezerobroadcast"=dword:00000000
"enabledeadgwdetect"=dword:00000001
"enabledhcp"=dword:00000000
"ipaddress"=hex(7):31,00,39,00,32,00,2e,00,31,00,36,00,38,00,2e,00,32,00,2e,00, 32,00,30,00,31,00,00,00,00,00
"subnetmask"=hex(7):32,00,35,00,35,00,2e,00,32,00,35,00,35,00,2e,00,32,00,35, 00,35,00,2e,00,30,00,00,00,00,00
"defaultgateway"=hex(7):31,00,39,00,32,00,2e,00,31,00,36,00,38,00,2e,00,32,00, 2e,00,32,00,35,00,34,00,00,00,00,00
"defaultgatewaymetric"=hex(7):31,00,00,00,00,00
"nameserver"="202.96.128.166,61.144.56.100"
"domain"=""
"disabledynamicupdate"=dword:00000000
"enableadapterdomainnameregistration"=dword:00000000
"interfacemetric"=dword:00000001
"tcpallowedports"=hex(7):30,00,00,00,00,00
"udpallowedports"=hex(7):30,00,00,00,00,00
"rawipallowedprotocols"=hex(7):30,00,00,00,00,00
"ntecontextlist"=hex(7):30,00,78,00,30,00,30,00,30,00,30,00,30,00,30,00,30,00, 32,00,00,00,00,00
"dhcpclassidbin"=hex:
"dhcpserver"="255.255.255.255"
"lease"=dword:00000e10
"leaseobtainedtime"=dword:45090a44
"t1"=dword:4509114c
"t2"=dword:45091692
"leaseterminatestime"=dword:45091854
"ipautoconfigurationaddress"="0.0.0.0"
"ipautoconfigurationmask"="255.255.0.0"
"ipautoconfigurationseed"=dword:92437cc6
"addresstype"=dword:00000000
保存reg然后放到你的服务器远程共享目录里,只需要修改上面红色字体的dns为你自己的dns.
如有人不知道怎么远程执行,举个列子,
比如我服务器名是sever,在服务器上建立的共享名是xx$ $表示隐藏,你可加也可以不加,
我把上面的注册表项保存为a.reg,那我就把这个a.reg注册表放到xx$的共享目录里,
那批处理就这样写:
echo off
regedit /s \\\\server\\xx$\\a.reg
cls
保存bat,把这个批处理丢到启动项就可以了,开机运行,1秒就改完了,及时生效,无需缓慢的等待!