Thursday, January 3, 2019


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



0 comments:

Post a Comment

Blog Archive

Translate

Popular Posts

Total Pageviews

Blog Archive