|
★☆☆☆☆☆☆☆☆☆ |
积分:285 |
发帖:317 |
登录:2024/3/26 |
注册:2006/6/28 |
|
(1楼)【原创】一段利用WSH修改和查看IP配置的代码
建议增加查询条件,更准确地修改指定网卡。 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,双击即可运行。
|