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("Network card 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 set is 220.192.32.103*/*/
//objIP.SetDNSServerSearchOrder(["220.192.0.130", "220.192.32.103"]);
arrAdp.push(arrIP.join("rn"));
enmPing.moveNext( );
}
WSH.Echo(arrAdp.join("rnrn"));
function GetVBArray(arr)
{
return arr !== null ? new VBArray(arr).toArray() : [];
}
Save as IpInfo.jse or IpInfo.js, double-click to run.
Execution result:
------ ---------------------
Windows Script Host
------------------------ -------
Network card 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:
Network card 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
--------------------------
Confirm
----- -----------------------