我使用以下内容获取IP地址(名为LAN2的NIC)
然后我需要更改第3个八位字节。以下是改变最后一个(到.15),但我不能将其修改为第3个 - 我该怎么做?
Dim HostIPAddress : HostIPAddress = ""
Dim objWMIService : Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Dim colAdapters : Set colAdapters = objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
Dim objAdapter
name = "LAN2"
Set wmi = GetObject("winmgmts://./root/cimv2")
deviceQry = "SELECT * FROM Win32_NetworkAdapter " & _
"WHERE NetConnectionId = '" & name & "'"
For Each adapter In wmi.ExecQuery(deviceQry)
addressQry = "SELECT * FROM Win32_NetworkAdapterConfiguration " & _
"WHERE Index = " & adapter.DeviceId
For Each config In wmi.ExecQuery(addressQry)
If Not IsNull(config.IPAddress) Then
HostIPAddress = Trim(config.IPAddress(0))
Exit For
End If
Next
Next
strIP = HostIPAddress
wscript.echo HostIPAddress
i = InStrRev(strIP, ".")
strIP = Left(strIP, i) & "15"