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:

  • Basic Syntax in VBScript Basic Syntax in VBScript Basic VBScript SyntaxRemember below points about VBScript Syntax. VBScript is loosely typed language that means you do not need to declare the variables with data type VBScript comments start … Read More
  • Data Types in vbscript Data Types in vbscript In vb script all variables are initialized with the data type called variant. But we can have below sub-types in vb script. In below table we have mentioned all sub data types in vb sc… Read More
  • What are the different operators in vbscript? What are the different operators in vbscript? At broad level there are 3 kinds of operators as mentioned below. Arithmetic Operators Comparison Operators Logical Operators Arithmetic Operators in the order of pre… Read More
  • Types of variables in Vbscript Types of variables in Vbscript Variables are storage locations in memory where we can store the the values.In vb script there are 3 types of variables. Scalar  - contains only one value. Array - contains many val… Read More
  • What is vbscript? What is vbscript? VBScript Intoduction Vb script is a scripting language used for performing administrative tasks in system programming.Vb script is a loosely typed language meaning we don't need to define the type of… Read More

0 comments:

Post a Comment

Blog Archive

Translate

Popular Posts

Total Pageviews

152,033

Blog Archive