Paypal Donate

List MAC Addresses

File
mac.vbs (2 views)

This script displays the MAC (Media Access Code) of all the network adapters installed in a system (should work on Windows 2000 and above).

The function returns the details as a string - in the example script this is simply shown on the screen.

' Script written by David Barrett
' Copyright 2009
' http://www.cedit.biz/
'
This script is licensed under the Creative Commons
' Attribution 2.5 Licence
' http://creativecommons.org/licenses/by/2.5/
'

' You are free to use it for both personal and
' commercial purposes, so long as full attribution
' is given to the author (David Barrett).
'
' This notice must not be removed
'
'
wscript.echo MacAddresses(".")

function MACAddresses(strComputer)
    dim objWMI, colItems, objItem
    dim strMac
    strMac=""  
    Set objWMI = GetObject("winmgmts:\\" & strComputer &  "\root\CIMV2")  
    Set colItems = objWMI.ExecQuery( _
        "SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=TRUE",,48)
    For Each objItem in colItems
        if objItem.MACAddress"" then
            strMac=strMac & objItem.Description & ": " & objItem.MACAddress & vbCrLf
        end if
    Next  
    MACAddresses = strMac
end function
Copyright © 2009 www.cedit.biz. All rights reserved.