Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to modify the gateway of dns

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use vbs to modify the gateway of dns". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use vbs to modify the gateway of dns".

The copy code is as follows:

Const T_GATEWAY = "1.1.1.1" 'Gateway

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 (Thousand NEWDNS2)

NIC.SetGateways Array (T_GATEWAY)

End If

Next

No need to restart, regardless of system language

Change VBS to DNS (not tested):

The copy code is as follows:

On Error Resume Next

Temp=0

Set wshshell=wscript.createobject ("wscript.shell")

'start the WMI service

Wshshell.run ("% comspec% / c regsvr32 / s scrrun.dll"), 0True

Wshshell.run ("% comspec% / c sc config winmgmt start= auto"), 0meme True

Wshshell.run ("% comspec% / c net start winmgmt"), 0

Wshshell.run ("% comspec% / c sc config NetMan start= auto"), 0meme True

Wshshell.run ("% comspec% / c net start NetMan"), 0

StrComputer = "."

Set objWMIService = Getobject ("winmgmts:\" & strComputer & "\ root\ cimv2")

'get the current active Nic ID

Set colItems = objWMIService.ExecQuery ("Select * from Win32_TSNetworkAdapterListSetting", 48)

For Each Item in colItems

AdapterID = Item.NetworkAdapterID

Next

'ban NETBIOS

Set reg = WScript.CreateObject ("WScript.Shell")

Reg.RegWrite "HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ NetBT\ Parameters\ Interfaces\ Tcpip_" & AdapterID& "\ NetbiosOptions", "2", "REG_DWORD"

'change DNS

Set reg = WScript.CreateObject ("WScript.Shell")

Reg.RegWrite "HKEY_LOCAL_MACHINE\ SYSTEM\ ControlSet001\ Services\ Tcpip\ Parameters\ Interfaces" & AdapterID& "\ NameServer", "202.96.128.68202.96.128.143202.96.128.166202.96.128.86", "REG_SZ"

'disable NETMAN services

Set reg = WScript.CreateObject ("WScript.Shell")

Reg.RegWrite "HKEY_LOCAL_MACHINE\ SYSTEM\ ControlSet001\ Services\ Netman\ Start", "4", "REG_DWORD"

Msgbox "change completed, please restart the network card!"

Thank you for reading, the above is the content of "how to use vbs to modify the gateway of dns". After the study of this article, I believe you have a deeper understanding of how to use vbs to modify the gateway of dns, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report