Monday 23 September 2013

How to get the IP Address of System in vbscript.

Here is a program that can be run to get the IP address of system.

'Get the WMI object for local computer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'get the Ip address configuration setting using Win32_NetworkAdapterConfiguration Class
'Filter IP configuration records using where condition - Where IPEnabled = True

Set IPConfigSet = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

 'Enumerate Each IP Address configuration

For Each IP_Configuration_Record in IPConfigSet

If Not IsNull(IP_Configuration_Record.IPAddress) Then

For i=0 to UBound(IP_Configuration_Record.IPAddress)
  str = str &  IP_Configuration_Record.IPAddress(i)
Next

    End If

Next

'Display IP Address of the system
msgbox str



No comments:

Post a Comment

Total Pageviews