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?
Asked
Active
Viewed 2.0k times
1 Answers
6
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.
-
thanks for the answer. It worked correctly. Regarding your comment on it being a poor choice, I agree. But we just need a simple and fast method to discourage inproper use of the tool. Since only a few copies of it will be distributed, we think this can be enough (for now). – carlossierra May 10 '13 at 16:49
-
@Alex, but how to get only the "active" network's mac address? – Sahil Mittal Apr 30 '14 at 10:08
-
Hope this is not too late @SahilMittal, the active one may be determined by checking other properties on the [Win32_NetworkAdapter from MSDN](https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx), look for **NetConnectionStatus = 2** + **Speed not null and > 0**, if both wired, wifi connected, mobile network connected, you will have to pick one based on **AdapterType**. – PatricK Apr 18 '17 at 23:28