以前做是随机生成IPX协议号,想换成通过IP来修改,代友如下,过程中出错请帮忙看看
IPX号只能是八位,判断当前如果在100以下前面就加6个0大于等于100就5个0
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 0x10 + 0x20)
For $objItem In $colItems
$LocalIP = $objItem.IPAddress(0)
Next
$ip4 = StringRegExpReplace($LocalIP,'(\d+\.){3}', '')
if $IP4<100 Then
$IPT="000000"
ElseIf $IP4>=100 Then
$ipt="00000"
EndIf
$IPX=$ipt&$ip4
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$objNetworkSettings = $objWMIService.Get("Win32_NetworkAdapterConfiguration")
$objNetworkSettings.SetIPXVirtualNetworkNumber(int($IPX))
[ 本帖最后由 jycel 于 2009-4-3 18:07 编辑 ] |