Created
October 19, 2020 19:32
-
-
Save JoeGlines/1deb9120b00387dc08e4f834992e669e to your computer and use it in GitHub Desktop.
Getting Unique IDs on User's computers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance Force | |
str := "`nProcessorId`t" . Get_ProcessorId() | |
str .= "`nSerialNumber`t" . Get_MotherboardSerialNumber() | |
str .= "`nMACAddress`t" . Get_MACAddress() | |
MsgBox, 4, , %str%`n`nCopy this to your Clipboard? | |
IfMsgBox, No | |
return | |
Clipboard := str | |
ExitApp | |
;--------------------------------------------------------- | |
Get_ProcessorId(){ ; info: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-processor | |
strComputer := "." | |
objWMIService := ComObjGet("winmgmts:\\" . strComputer . "\root\cimv2") | |
WQLQuery := "Select * From Win32_Processor" | |
colCPU := objWMIService.ExecQuery(WQLQuery)._NewEnum | |
while colCPU[objCPU] | |
return objCPU.ProcessorId | |
} | |
;--------------------------------------------------------- | |
Get_MotherboardSerialNumber(){ ; source: https://www.autohotkey.com/boards/viewtopic.php?style=1&t=24346 ; example: 120700577302842 | |
While (ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2") | |
.ExecQuery("Select * From Win32_BaseBoard")._NewEnum)[objMBInfo] | |
return objMBInfo["SerialNumber"] | |
} | |
;--------------------------------------------------------- | |
Get_MACAddress(){ ; source: https://www.autohotkey.com/boards/viewtopic.php?style=1&t=24346 ; example: 30:85:A9:8E:F9:E2 | |
objWMIService := | |
colItems := ComObjGet("winmgmts:{impersonationLevel = impersonate}!\\.\root\cimv2") | |
.ExecQuery("Select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")._NewEnum | |
while colItems[objItem] | |
if objItem.IPAddress[0] = A_IPAddress1 | |
return objItem.MACAddress | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment