Shortcut Menu

Skip

Main Navigation

Choose your language


ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


Configuring Client-Side Networking through VBScript

Assign the DNS Domain for a Network Adapter
Assign a Static IP Address
Assign the WINS Server for a Network Adapter
Enable Dead Gateway Detection for All Network Adapters
Enable DNS on All Network Adapters
Enable IPFilter Security on All Network Adapters
Enable IPSec on a Network Adapter
Enable DHCP
Enable PMTU Discovery on all Network Adapters
Modify the Allowed Number of TCP Connections
Modify ARP Queries to Use EtherSNAP
Modify ARP Queries to Use Source Routing
Modify Dynamic DNS Registration for a Network Adapter
Modify the DNS Suffix Search Order for All Network Adapters
Modify the DNS Server Search Order for a Network Adapter
Modify the Database Path for all Network Adapters
Modify the Default Time-to-Live for All Network Adapters
Modify the Forward Buffer Memory for All Network Adapters
Modify the Gateways for a Network Adapter
Modify the IGMP Level for All Network Adapters
Modify the IP Connection Metric for a Network Adapter
Modify the IPX Frame Type
Modify the IPX Virtual Network Number
Modify the Keep Alive Interval for all Network Adapters
Modify Keep Alive Time for All Network Adapters
Modify the Maximum Allowed TCP Connection Retransmissions
Modify the Maximum Allowed TCP Data Retransmissions
Modify the MTU for all Network Adapters
Modify the Number of Allowed Forward Packets
Modify NetBIOS Use on a Network Adapter
Modify PMTUBH Detection on All Network Adapters
Modify the TCP Window Size for All Network Adapters
Modify Urgent Pointer Use for All Network Adapters
Modify Zero-Broadcast Use for All Network Adapters
Renew All DHCP Leases
Renew the DHCP Lease for a Network Adapter


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.



Assign the DNS Domain for a Network Adapter


On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colNetCards = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objNetCard in colNetCards Wscript.Echo objNetCard.SetDNSDomain("fabrikam.com") Next
Sets the DNS domain for a TCP/IP-bound network adapter.

Assign a Static IP Address


Sets the IP address of a computer to 192.168.1.141, and sets the IP gateway to 192.168.1.100.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
 
For Each objNetAdapter in colNetAdapters
    errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
    errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
    If errEnable = 0 Then
        WScript.Echo "The IP address has been changed."
    Else
        WScript.Echo "The IP address could not be changed."
    End If
Next
	

Assign the WINS Server for a Network Adapter


Sets the primary and secondary WINS server for a TCP/IP-bound network adapter
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    strPrimaryServer = "192.168.1.100"
    strSecondaryServer = "192.168.1.200"
    objNetCard.SetWINSServer strPrimaryServer, strSecondaryServer
Next
	

Enable Dead Gateway Detection for All Network Adapters


Configures all network adapters on a computer to automatically detect dead gateways.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDeadGWDetect(True)
	

Enable DNS on All Network Adapters


Enables DNS for all network adapters on a computer, configuring the host name to fabrikam1 and designating hr.fabrikam.com and research.fabrikam.com as DNS search order suffixes.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
strHostName = "fabrikam1"
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.EnableDNS strHostName, , , arrDNSSuffixes
	

Enable IPFilter Security on All Network Adapters


Enables IP filter security for all the network adapters installed in a computer.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.EnableIPFilterSec(True)
	

Enable IPSec on a Network Adapter


Enables IP security for a network adapter. In this script, all TCP and UDP ports as well as all IP protocols are allowed; hence the value 0 is passed to the EnableIPSec method in each case. If only specific ports or protocols are allowed, these should be passed in the form of arrays.
On Error Resume Next
 
Const ALLOW_ALL = 0
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrPermittedTCPPorts = Array(ALLOW_ALL)
    arrPermittedUDPPorts = Array(ALLOW_ALL)
    arrPermittedIPProtocols = Array(ALLOW_ALL)
    objNetCard.EnableIPSec arrPermittedTCPPorts, arrPermittedUDPPorts, _
        arrPermittedIPProtocols
Next
	

Enable DHCP


Enables the DHCP client service on a computer. The computer will then use DHCP to obtain an IP address rather than use a static IP address.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
 
For Each objNetAdapter In colNetAdapters
    errEnable = objNetAdapter.EnableDHCP()
Next
	

Enable PMTU Discovery on all Network Adapters


Enables a computer to automatically discover the maximum transmission unit on a network. To disable auto-discovery of the maximum transmission unit, pass the value False to the SetPMTUDiscovery method.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetPMTUDiscovery(True)
	

Modify the Allowed Number of TCP Connections


Sets the maximum allowed number of simultaneously-opened TCP connections on a computer to 10.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPNumConnections(10)
	

Modify ARP Queries to Use EtherSNAP


Configures the network adapters on a computer to use 802.3 SNAP encoding for Ethernet packets.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetArpUseEtherSNAP(True)
	

Modify ARP Queries to Use Source Routing


Configures TCP/IP to always use source routing on all Token Ring networks.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetArpAlwaysSourceRoute(True)
	

Modify Dynamic DNS Registration for a Network Adapter


Configures dynamic DNS registration for a network adapter.
On Error Resume Next
 
Const FULL_DNS_REGISTRATION = True
Const DOMAIN_DNS_REGISTRATION = False
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.SetDynamicDNSRegistration FULL_DNS_REGISTRATION, _
        DOMAIN_DNS_REGISTRATION
Next
	

Modify the DNS Suffix Search Order for All Network Adapters


Configure a computer to use two DNS suffixes -- hr.fabrikam.com and research.fabrikam.com -- when performing DNS searches. Note that even if a computer uses only a single DNS suffix, this value must still be passed to the SetDNSSuffixSearchOrder method as an array (in that case, an array with a single element).
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes)
	

Modify the DNS Server Search Order for a Network Adapter


Configures a TCP/IP-bound network adapter to use two DNS servers: 192.168.1.100 and 192.168.1.200. Note that even if a computer only uses one DNS server, the IP address of that server must still be passed to the SetDNSServerSearchOrder method as an array (in that case, an array with only one element).
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrDNSServers = Array("192.168.1.100", "192.168.1.200")
    objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next
	

Modify the Database Path for all Network Adapters


Sets the path to the standard Internet database files (HOSTS, LMHOSTS, NETWORKS, PROTOCOLS) used by the Windows Sockets interface.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDatabasePath("c:\windows\system32\drivers\etc")
	

Modify the Default Time-to-Live for All Network Adapters


Sets the default time-to-live value in the header of outgoing IP packets to 64 (this represents the number of routers an IP packet can pass through before being discarded). Valid TTL values range from 1 to 255, with a default value of 32.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDefaultTTL(64)
	

Modify the Forward Buffer Memory for All Network Adapters


Configures the forward buffer memory for all network adapters on a computer. Values should be supplied in multiples of 256.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetForwardBufferMemory(74240)
	

Modify the Gateways for a Network Adapter


Configures two gateways -- 192.168.1.100 and 192.168.1.200 -- for a network adapter. Note that even if only one gateway is specified, the IP address for that gateway must be passed as part of an array (in that case, an array with only a single element).
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrGateways = Array("192.168.1.100", "192.168.1.200")
    objNetCard.SetGateways(arrGateways)
Next
	

Modify the IGMP Level for All Network Adapters


Disables IGMP multicasting on a computer. To enable IP multicasting, pass the value 1 to the SetIGMPLevel method. Pass the value 2 to allow both IP and IGMP multicasting.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIGMPLevel(0)
	

Modify the IP Connection Metric for a Network Adapter


Sets the IP connection metric for a network adapter to 100. Connection metrics can range from 1 to 9,999, with a default value of 1.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.SetIPConnectionMetric(100)
Next
	

Modify the IPX Frame Type


Configures the IPX network number and frame type for a network adapter. In this case, the frame type is set to AUTO (value of 255). Because the frame type is set to AUTO, the network number must be set to 0. Note that both the network number and the frame types must be passed as arrays, even if there is only a single element (for example, one frame type).
On Error Resume Next
 
Const AUTO = 255
Const NETWORK_NUMBER = 0
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrNetworkNumber = Array(NETWORK_NUMBER)
    arrFrameTypes = Array(AUTO)
    objNetCard.SetIPXFrameTypeNetworkPairs arrNetworkNumber, arrFrameTypes
Next
	

Modify the IPX Virtual Network Number


Sets the IPX internal network number of a computer to network number 5.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPXVirtualNetworkNumber(5)
	

Modify the Keep Alive Interval for all Network Adapters


Configures the keep alive interval for all network adapters on a computer to 300,00 milliseconds (5 minutes).
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetKeepAliveInterval(300000)
	

Modify Keep Alive Time for All Network Adapters


Configures the keep alive time for all network adapters on a computer to 300,000 milliseconds (5 minutes).
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetKeepAliveTime(300000)
	

Modify the Maximum Allowed TCP Connection Retransmissions


Configures the number of times TCP will retransmit a connection attempt before abandoning the effort. Valid values range from 0 to 0xFFFFFFFF.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPMaxConnectRetransmissions(10)
	

Modify the Maximum Allowed TCP Data Retransmissions


Configures the number of times TCP will attempt to retransmit an individual data segment before abandoning the effort. Valid values range from 0 to 0xFFFFFFFF.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPMaxDataRetransmissions(10)
	

Modify the MTU for all Network Adapters


Configures the maximum transmission unit for all network adapters installed in a computer. Valid values range from a minimum of 68 bytes to the maximum number of bytes supported by the network.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetMTU(68)
	

Modify the Number of Allowed Forward Packets


Configures the number of forward packets allocated to the router packet queue. Valid values range from 1 to 0xFFFFFFFE.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetNumForwardPackets(1)
	

Modify NetBIOS Use on a Network Adapter


Enables NetBIOS for a network adapter. To enable NetBIOS via DHCP, pass the value 0 to the SetTCPIPNetBIOS method (instead of the value 1). Pass the value 2 to disable NetBIOS.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.SetTCPIPNetBIOS(1)
Next
	

Modify PMTUBH Detection on All Network Adapters


Enables the auto-discovery of black hole routers when determining the maximum transmission unit on a network. To disable auto-discovery of black hole routers, pass the value False to the SetPMTUBHDetect method.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetPMTUBHDetect(True)
	

Modify the TCP Window Size for All Network Adapters


Sets the TCP window size for all network adapters on a computer. Valid windows sizes range from 0 to 65,535 bytes.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPWindowSize(65535)
	

Modify Urgent Pointer Use for All Network Adapters


Configures a computer to use the RFC 1122 specification for urgent data rather than the mode used by Berkeley Software Design- (BSD) derived systems. To use the BSD mode instead, pass the value False to the SetTcpRFC1122UrgentPointer method.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTcpUseRFC1122UrgentPointer(True)
	

Modify Zero-Broadcast Use for All Network Adapters


Configures a computer to use zero-broadcasts (0.0.0.0) rather than one-broadcasts (255.255.255.255). Zero-broadcasts are the default used on systems derived from BSD implementations.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPUseZeroBroadcast(True)
	

Renew All DHCP Leases


Renews all the DHCP leases currently in use on a computer.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.RenewDHCPLeaseAll()
	

Renew the DHCP Lease for a Network Adapter


Renews the DHCP lease for each TCP/IP-bound network adapter in a computer.
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.RenewDHCPLease()
Next