IPアドレスなどのネットワーク情報表示のVBScriptサンプルです。
Win32_NetworkAdapterConfiguration class
https://msdn.microsoft.com/library/windows/hardware/aa394217
IPEnabled = Trueで有効なインターフェイスの情報を表示しています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
Dim s strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem in colItems s = "Caption: " & objItem.Caption & vbCRLF For Each strGateway in objItem.DefaultIPGateway s = s & "DefaultIPGateway: " & strGateway & vbCRLF Next s = s & "Description: " & objItem.Description & vbCRLF s = s & "DNSDomain: " & objItem.DNSDomain & vbCRLF s = s & "DNSHostName: " & objItem.DNSHostName & vbCRLF For Each strDns in objItem.DNSServerSearchOrder s = s & "DNSServerSearchOrder: " & strDns & vbCRLF Next s = s & "Index: " & objItem.Index & vbCRLF For Each strAddress in objItem.IPAddress s = s & "IPAddress: " & strAddress & vbCRLF next s = s & "IPEnabled: " & objItem.IPEnabled & vbCRLF For Each strIPSubnet in objItem.IPSubnet s = s & "IPSubnet: " & strIPSubnet & vbCRLF next s = s & "MACAddress: " & objItem.MACAddress & vbCRLF s = s & "ServiceName: " & objItem.ServiceName & vbCRLF s = s & "SettingID: " & objItem.SettingID & vbCRLF s = s & "WINSPrimaryServer: " & objItem.WINSPrimaryServer & vbCRLF s = s & "WINSSecondaryServer: " & objItem.WINSSecondaryServer & vbCRLF Wscript.Echo s Next |
IPEnabled = Trueが無いとIPAddressがNULLなインターフェイスも表示しようとしてエラーが表示されます。