VBScript: Get a computer's IP address(es)

Filed under:
Printer-friendly versionSend to friendPDF version
No votes yet

Returns a string of addresses, separated by pipe (|), with a leading pipe:
|192.168.0.12|172.16.31.64|10.1.1.2

  1. Function GetIPAddress
  2. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
  3. Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE",,48)
  4.  
  5. ipList = ""
  6.  
  7. For Each objItem In colItems
  8. ipList = ipList & "|" & Join(objItem, "|")
  9. Next
  10.  
  11. GetIPAddress = ipList
  12. End Function

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <hr> <span>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options