KB-34029: Retrieving the IP address via scripts.

Question:

How can I get the IP address of the computer via scripts?

Solution:

To do so, you can write a script similar to the one in the following example:

strcomputer = “.”
Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colItems = objWMIService.ExecQuery(“Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True”)

For Each objitem In colitems

strIPAddress = Join(objitem.IPAddress, “,”)
IP = Split(stripaddress, “,”)

Call MsgBox(IP(0))

Next

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *