Pages

Friday, 15 June 2012

Get IP Address of machine - VBScript


On Error Resume Next
Dim IPADDRES 
Dim WshShell 


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")


Set WshShell=CreateObject("WScript.Shell")


For Each objNicConfig In colNicConfigs
      For Each strIPAddress In objNicConfig.IPAddress
             IPADDRES = strIPAddress
      Next
Next


msgbox IPADDRES


Set WshShell = Nothing
WScript.Quit

No comments:

Post a Comment