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 Get MAC Address and NIC info

Keywords: 	 WMI Get MAC Address and NIC info

Sample 1 (new Way):
strComputer = "."
objWMIService = GetObject(StrCat("winmgmts:!\\" , strComputer , "\root\cimv2"))
colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")
ForEach objAdapter In colAdapters
   AdapterType = objAdapter.AdapterType
   Caption  = objAdapter.Caption
   Manufacturer = objAdapter.Manufacturer
   MACAddress  = objAdapter.MACAddress
   Status  = objAdapter.Status
   Name = objAdapter.Name
   PermanentAddress = objAdapter.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)
Next


Sample 2 (old way):

ComputerName = ""; or "Peanuts" 

Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer(ComputerName)
Security = Service.Security_
Security.ImpersonationLevel = 3
Adapters = Service.InstancesOf("Win32_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)




Article ID:   W15793
File Created: 2012:03:15:13:53:48
Last Updated: 2012:03:15:13:53:48