CMD and VBS modify IP address and DNS implementation code _vbs

Source: Internet
Author: User
Modify IP

cmd/c netsh interface ip set address name= "Local Area Connection" Source=static addr=211.82.56.253 mask=255.255.255.0 gateway=211.82.56.1 Gwmetric=1

Modify DNS
cmd/c netsh interface ip set DNS name= "Local Area Connection" Source=static addr=202.99.192.66


To configure or update an IP address:
WMIC Nicconfig where index=0 call EnableStatic ("192.168.1.5"), ("255.255.255.0"), index=0 description is configured with network interface 1.


To Configure a gateway (default route):
WMIC Nicconfig where index=0 call SetGateways ("192.168.1.1"), (1)


VBS

Const T_gateway = "211.82.56.1" Gateway
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.