We recommend that you add query conditions to modify the specified Nic more accurately. I am an iron-Tong Line. This looks like a good wsh function. If you like vbs, you can use vbs for better functionality.
The Code is as follows:
Var WMI = GetObject ("winmgmts: // 127.0.0.1 ");
Var SQL = "select * from Win32_NetworkAdapterConfiguration where IPEnabled = true ";
Var enmPing = new Enumerator (WMI. ExecQuery (SQL ));
Var arrAdp = new Array;
While (! EnmPing. atEnd ())
{
Var arrIP = new Array;
Var objIP = enmPing. item ();
ArrIP. push ("Nic Description:" + objIP. Description );
ArrIP. push ("hardware address:" + objIP. MACAddress );
ArrIP. push ("Dynamic Address:" + (objIP. DHCPEnabled? "Yes": "no "));
ArrIP. push ("Network Address:" + GetVBArray (objIP. IPAddress ));
ArrIP. push ("domain name resolution:" + GetVBArray (objIP. DNSServerSearchOrder ));
ArrIP. push ("subnet mask:" + GetVBArray (objIP. IPSubnet ));
ArrIP. push ("Default Gateway:" + GetVBArray (objIP. DefaultIPGateway ));
/* Set the preferred DNS to 220.192.0.130, and the second DNS to 220.192.32.103 */
// ObjIP. SetDNSServerSearchOrder (["220.192.0.130", "220.192.32.103"]);
ArrAdp. push (arrIP. join ("\ r \ n "));
EnmPing. moveNext ();
}
WSH. Echo (arrAdp. join ("\ r \ n "));
Function GetVBArray (arr)
{
Return arr! = Null? New VBArray (arr). toArray (): [];
}
Save it as IpInfo. jse or IpInfo. js and double-click it to run it.
Execution result:
The Code is as follows:
---------------------------
Windows Script Host
---------------------------
NIC Description: Realtek RTL8139 Family PCI Fast Ethernet NIC
Hardware address: 00: E0: 4C: E7: 15: A2
Dynamic Address: Yes
Network Address: 169.254.44.245
Domain name resolution:
Subnet Mask: 255.255.0.0
Default Gateway:
Nic Description: WAN (PPP/SLIP) Interface
Hardware address: 00: 53: 45: 00: 00: 00
Dynamic Address: No
Network Address: 122.89.157.174
Domain name resolution: 222.45.1.122, 222.45.1.40
Subnet Mask: 255.255.255.255
Default Gateway: 122.89.157.174
---------------------------
OK
---------------------------