2008年1月30日水曜日

[VBScript]IPアドレスの取得

'
' IPアドレスの取得
'

Option Explicit

Dim oWMIService, oIPConfigSet, oIPConfig
Dim sComputer, sAddress

sComputer = "."
Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set oIPConfigSet = oWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each oIPConfig in oIPConfigSet

For Each sAddress In oIPConfig.IPAddress
WScript.Echo sAddress
Next

Next

Set oIPConfig = Nothing
Set oIPConfigSet = Nothing
Set oWMIService = Nothing

0 件のコメント: