Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: adamchapman on October 25, 2012, 02:09:34 PM

Title: getting MAC address in VB
Post by: adamchapman 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(objItem.MACAddress)
      else
      msgBox("mac address is null?")
    End If

Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

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
Title: Re: getting MAC address in VB
Post by: BR549 on October 30, 2012, 12:00:46 PM
OK I 'll bite WHY would you want to be to get the MAC address ?

(;-) tp