Hello Guest it is March 02, 2024, 10:37:47 PM

Author Topic: getting MAC address in VB  (Read 2848 times)

0 Members and 1 Guest are viewing this topic.

getting MAC address in VB
« on: October 25, 2012, 02:09:34 PM »
I've found a piece of code that should find the MAC address of the host machine in VBscript.

However, I can't seem to display the MAC address object for some reason.
The code is:

On Error Resume Next
Dim strComputer
Dim objWMIService
Dim colItems

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration")

For Each objItem in colItems

   If Not IsNull(objItem.MACAddress) Then
        'Wscript.Echo objItem.MACAddress
      msgBox("mac address is null?")
    End If


I have no idea why no message box pops up, and I don't know if ojbItem.MACAddress is a string.

If anybody could help I would be massively grateful

Offline BR549

  •  6,965 6,965
    • View Profile
Re: getting MAC address in VB
« Reply #1 on: October 30, 2012, 12:00:46 PM »
OK I 'll bite WHY would you want to be to get the MAC address ?

(;-) tp