用vbs實(shí)現(xiàn)修改dns的網(wǎng)關(guān)腳本
更新時(shí)間:2008年05月31日 13:04:30 作者:
這篇文章主要為大家介紹了用vbs實(shí)現(xiàn)修改dns的代碼,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
Const T_GATEWAY = "1.1.1.1" '網(wǎng)關(guān)
Const T_NEWDNS1 = "2.2.2.2" 'DNS1
Const T_NEWDNS2 = "3.3.3.3" '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
無須重新啟動(dòng),不管系統(tǒng)語言
VBS改DNS(未測(cè)試):
復(fù)制代碼 代碼如下:
On Error Resume Next
temp=0
set wshshell=wscript.createobject("wscript.shell")
'啟動(dòng)WMI服務(wù)
wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"),0,True
wshshell.run ("%comspec% /c sc config winmgmt start= auto"),0,True
wshshell.run ("%comspec% /c net start winmgmt"),0
wshshell.run ("%comspec% /c sc config NetMan start= auto"),0,True
wshshell.run ("%comspec% /c net start NetMan"),0
strComputer = "."
Set objWMIService = Getobject("winmgmts:\" & strComputer & "\root\cimv2")
'得到當(dāng)前活動(dòng)網(wǎng)卡ID
Set colItems = objWMIService.ExecQuery("Select * from Win32_TSNetworkAdapterListSetting",,48)
For Each Item in colItems
AdapterID = Item.NetworkAdapterID
Next
'禁NETBIOS
Set reg = WScript.CreateObject("WScript.Shell")
reg.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_"&AdapterID&"\NetbiosOptions","2","REG_DWORD"
'更改DNS
Set reg = WScript.CreateObject("WScript.Shell")
reg.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces"&AdapterID&"\NameServer","202.96.128.68,202.96.128.143,202.96.128.166,202.96.128.86","REG_SZ"
'禁NETMAN服務(wù)
Set reg = WScript.CreateObject("WScript.Shell")
reg.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Netman\Start","4","REG_DWORD"
msgbox "更改完成,請(qǐng)重啟網(wǎng)卡!"
相關(guān)文章
vbs實(shí)現(xiàn)web自動(dòng)登錄網(wǎng)站的方法
這篇文章主要介紹了vbs實(shí)現(xiàn)web自動(dòng)登錄網(wǎng)站,首先編寫vbs,接著配置為開機(jī)自啟,這個(gè)比較簡(jiǎn)單,只需要將這個(gè)vbs文件放到下面目錄中就可以了,需要的朋友可以參考下2022-04-04用vbs對(duì)文本文件的內(nèi)容進(jìn)行排序
用vbs對(duì)文本文件的內(nèi)容進(jìn)行排序...2007-04-04encrypt.vbs 內(nèi)容加密vbs實(shí)現(xiàn)代碼
內(nèi)容加密vbs實(shí)現(xiàn)代碼 本人不能保證文件能改過來.請(qǐng)大家先測(cè)試下,注意備份。2009-09-09VBS 提取狗狗影視中的ED2K連接的實(shí)現(xiàn)代碼
這篇文章主要介紹了通過VBS 提取狗狗影視中的ED2K連接,需要的朋友可以參考下2013-07-07用vbs實(shí)現(xiàn)將剪切板的unix格式的內(nèi)容處理成pc格式的代碼
用vbs實(shí)現(xiàn)將剪切板的unix格式的內(nèi)容處理成pc格式的代碼...2007-10-10