CMD和vbs修改 IP地址及DNS的實(shí)現(xiàn)代碼
更新時(shí)間:2009年01月05日 12:14:23 作者:
命令行下對(duì)IP地址及DNS的操作 包括netsh和wmic兩個(gè)版本 和vbs下對(duì)網(wǎng)關(guān)和DNS的修改
修改IP
cmd /c netsh interface ip set address name=" 本地連接" source=static addr=211.82.56.253 mask=255.255.255.0 gateway=211.82.56.1 gwmetric=1
修改DNS
cmd /c netsh interface ip set dns name="本地連接" source=static addr=202.99.192.66
配置或更新IP地址:
wmic nicconfig where index=0 call enablestatic("192.168.1.5"), ("255.255.255.0") ;index=0說明是配置網(wǎng)絡(luò)接口1。
配置網(wǎng)關(guān)(默認(rèn)路由):
wmic nicconfig where index=0 call setgateways("192.168.1.1"),(1)
vbs
Const T_GATEWAY = "211.82.56.1" '網(wǎng)關(guān)
Const T_NEWDNS1 = "202.99.192.66" 'DNS1
Const T_NEWDNS2 = "60.221.248.43" 'DNS2
strWinMgmt="winmgmts:{impersonationLevel=impersonate}"
Set NICS = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")
For Each NIC In NICS
If NIC.IPEnabled Then
NIC.SetDNSServerSearchOrder Array(T_NEWDNS1,T_NEWDNS2)
NIC.SetGateways Array(T_GATEWAY)
End If
Next
cmd /c netsh interface ip set address name=" 本地連接" source=static addr=211.82.56.253 mask=255.255.255.0 gateway=211.82.56.1 gwmetric=1
修改DNS
cmd /c netsh interface ip set dns name="本地連接" source=static addr=202.99.192.66
配置或更新IP地址:
wmic nicconfig where index=0 call enablestatic("192.168.1.5"), ("255.255.255.0") ;index=0說明是配置網(wǎng)絡(luò)接口1。
配置網(wǎng)關(guān)(默認(rèn)路由):
wmic nicconfig where index=0 call setgateways("192.168.1.1"),(1)
vbs
Const T_GATEWAY = "211.82.56.1" '網(wǎng)關(guān)
Const T_NEWDNS1 = "202.99.192.66" 'DNS1
Const T_NEWDNS2 = "60.221.248.43" 'DNS2
strWinMgmt="winmgmts:{impersonationLevel=impersonate}"
Set NICS = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")
For Each NIC In NICS
If NIC.IPEnabled Then
NIC.SetDNSServerSearchOrder Array(T_NEWDNS1,T_NEWDNS2)
NIC.SetGateways Array(T_GATEWAY)
End If
Next
相關(guān)文章
VBScript之通過對(duì)比注冊(cè)表查找隱藏的服務(wù)
系統(tǒng)服務(wù)有可能被 rootkit 隱藏,但有些時(shí)候我們?nèi)钥梢詮淖?cè)表中找到相關(guān)的信息。建議以管理員權(quán)限運(yùn)行,否則有些服務(wù)列舉不出來或出現(xiàn)錯(cuò)誤的提示2013-09-09
用vbs實(shí)現(xiàn)配置靜態(tài) IP 地址
用vbs實(shí)現(xiàn)配置靜態(tài) IP 地址...2007-05-05
MSScriptControl.ScriptControl組件的用法實(shí)例
這篇文章主要介紹了MSScriptControl.ScriptControl組件的用法實(shí)例,需要的朋友可以參考下2014-08-08
利用wscript執(zhí)行文件[包括可執(zhí)行exe文件]vbs腳本
利用wscript執(zhí)行文件[包括可執(zhí)行exe文件]vbs腳本...2007-02-02
用VBS模擬實(shí)現(xiàn)PHP的sha1_file函數(shù)效果代碼
用VBS模擬實(shí)現(xiàn)PHP的sha1_file函數(shù)效果代碼,需要的朋友可以參考下。2011-01-01

