WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WMI and Get IPAddress Property

Keywords: 	 WMI and Get IPAddress Property

Question:

I want to configure my network interfaces without our users having the necessary authority. I created a program using WMI and the WIN32_NetworkAdapterConfiguration class to go through all LAN interfaces.

But how can I read the IPaddress propertie. This is an array of strings, and can't retrieve the address

Answer:

This should work:
Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer()
Security = Service.Security_
Security.ImpersonationLevel = 3
Class = "Win32_NetworkAdapterConfiguration"
Instance = Service.InstancesOf(Class)
hEnum = ObjectCollectionOpen(Instance)
Obj = ObjectCollectionNext(hEnum)
If Obj != 0 
  Message(Class, StrCat("Description"," = ",Obj.Description,@CRLF,"Ip Address = ",Obj.ipaddress(0)))
Endif
ObjectCollectionClose(hEnum)
ObjectClose(Instance)
ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)

Article ID:   W15792
File Created: 2003:05:13:11:30:06
Last Updated: 2003:05:13:11:30:06