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


Related Posts:

  • What is Windows Script Host? What is Windows Script Host? WSH is a scripting host for Windows Script compatible scripting engines.WSH supports various scripting languages like vbscript, javascript, python etc.You can do below operations using WSH… Read More
  • Dictionary Object in vb script Example Dictionary Object in vb script Example Dictionary object is used to store the data in key-item pairs in qtp.A Dictionary object is just like an associative array.It stores the data in the form of key-item pairs.Each k… Read More
  • Error handling in VBScript Error handling in VBScript VBScript provides below statements and keywords to handle errors. on error resume next Err object - err.description, err.number Sample code to handle the error is given below If er… Read More
  • Regular Expressions in vb script example Regular Expressions in vb script example Regular expressions BasicsDefinition :A regular expression is a pattern of characters(meta characters and special characters). General Applications of Regular Expression… Read More
  • File system object in vb script File system object in vb script Filesystemobject can be used to work with drives, folders, and files.Filesystemobject  has methods and properties that allow us to create, delete, gain information about, and gener… Read More

0 comments:

Post a Comment

Blog Archive

Translate

Popular Posts

Total Pageviews

150,594

Blog Archive