Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


WMI Get MAC Address and NIC info

Keywords: 	 WMI Get MAC Address and NIC info

ComputerName = "Peanuts" 

Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer(ComputerName)
Security = Service.Security_
Security.ImpersonationLevel = 3

Adapters = Service.InstancesOf("CIM_NetworkAdapter")

hEnum = ObjectCollectionOpen(Adapters)
swNameList=""
While 1
	Nic = ObjectCollectionNext(hEnum)
	If Nic == 0 Then Break
	AdapterType = Nic.AdapterType
	Caption  = Nic.Caption 
	Manufacturer = Nic.Manufacturer
	MACAddress  = Nic.MACAddress 
	Status  = Nic.Status   ;
	Name = Nic.Name  ;
	PermanentAddress = Nic.PermanentAddress  ;
	Line = StrCat("AdapterType: ",AdapterType ,@crlf,"Caption: ",Caption ,@crlf,"Manufacturer: ",Manufacturer,@crlf,"MACAddress: ",MACAddress,@crlf)
	Line = StrCat(Line,"Name: ",Name,@crlf,"Status: ",Status,@crlf)
	Message("",Line)
	ObjectClose(Nic)
EndWhile

ObjectCollectionClose(hEnum)

ObjectClose(Adapters)

ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)