使用VBScript获取Mac地址

时间:2013-05-10 16:17:10

标签: vbscript mac-address

我正在尝试为我正在编写的Excel(适用于Windows)应用程序提供一些基本级别的保护。我正在考虑使用机器的mac地址生成许可证文件。我的问题是:如何使用VBScript获取Mac地址?

1 个答案:

答案 0 :(得分:5)

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 

然而MAC可能是一个糟糕的选择; What's a good way to uniquely identify a computer?

这将返回所有物理适配器,但对我来说,我也看到了Cisco Systems VPN Adapter for 64-bit Windows,我不会将其描述为物理。