Home > Web Front-end > JS Tutorial > A piece of code that uses WSH to modify and view IP configuration_javascript skills

A piece of code that uses WSH to modify and view IP configuration_javascript skills

WBOY
Release: 2016-05-16 19:04:55
Original
1551 people have browsed it
Copy code 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("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:
Copy code The code is as follows:

------ ---------------------
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
----- -----------------------

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template