|
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("網卡說明:" + objIP.Description);
arrIP.push("硬件地址:" + objIP.MACAddress);
arrIP.push("動態地址:" + (objIP.DHCPEnabled ? "是" : "否"));
arrIP.push("網絡地址:" + GetVBArray(objIP.IPAddress));
arrIP.push("域名解析:" + GetVBArray(objIP.DNSServerSearchOrder));
arrIP.push("子網掩碼:" + GetVBArray(objIP.IPSubNET));
arrIP.push("默認網關:" + GetVBArray(objIP.DefaultIPGateway));
/* 將首選DNS設置為220.192.0.130,第二DNS設置為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/r/n"));
function GetVBArray(arr)
{
return arr !== null ? new VBArray(arr).toArray() : [];
}
另存為IpInfo.jse或者IpInfo.js,雙擊即可運行。
執行結果:
復制代碼 代碼如下:
---------------------------
Windows 腳本宿主
---------------------------
網卡說明:Realtek RTL8139 Family PCI Fast EtherNET NIC
硬件地址:00:E0:4C:E7:15:A2
動態地址:是
網絡地址:169.254.44.245
域名解析:
子網掩碼:255.255.0.0
默認網關:
網卡說明:WAN (PPP/SLIP) Interface
硬件地址:00:53:45:00:00:00
動態地址:否
網絡地址:122.89.157.174
域名解析:222.45.1.122,222.45.1.40
子網掩碼:255.255.255.255
默認網關:122.89.157.174
---------------------------
確定
---------------------------
JavaScript技術:一段利用WSH修改和查看IP配置的代碼,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。