Search code examples
vbscriptmac-address

Get Mac Address Using VBScript


I'm trying to put some basic level of protection to an Excel (for Windows) application I'm writing. I was thinking on generating a license file using the machine's mac address. My question is: how can I get the Mac Address using VBScript?


Solution

  • dim WMI:  set WMI = GetObject("winmgmts:\\.\root\cimv2")
    dim Nads: set Nads = WMI.ExecQuery("Select * from Win32_NetworkAdapter where physicaladapter=true") 
    dim nad
    for each Nad in Nads
        if not isnull(Nad.MACAddress) then Wscript.Echo Nad.description, Nad.MACAddress   
    next 
    

    However MAC can be a poor choice; What's a good way to uniquely identify a computer?.

    This will return all physical adapters, but for me I also see my Cisco Systems VPN Adapter for 64-bit Windows which I would not describe as physical.