Ways of getting a hardware based unique identifier

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 665
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Ways of getting a hardware based unique identifier

Post by Grovkillen » Wed Apr 01, 2020 6:35 pm

Code: Select all

Let>RP_WAIT=1
Let>RP_WINDOWMODE=0

PutClipBoard>clean...
Let>COMMAND_LINE_STRING=cmd /c powershell (Get-CimInstance -Class Win32_ComputerSystemProduct).UUID | clip
RunProgram>COMMAND_LINE_STRING
GetClipBoard>UUID_1
Trim>UUID_1,UUID_1
MDL>UUID_1

// will render same UUID as above
Let>COMMAND_LINE_STRING=cmd /c wmic csproduct get UUID | clip
RunProgram>COMMAND_LINE_STRING
GetClipBoard>CLIP
Separate>CLIP,%CRLF%,TEMP
Let>UUID_2=TEMP_3
Trim>UUID_2,UUID_2
MDL>UUID_2

Let>COMMAND_LINE_STRING=cmd /c wmic DISKDRIVE get SerialNumber | clip
RunProgram>COMMAND_LINE_STRING
GetClipBoard>CLIP
Separate>CLIP,%CRLF%,TEMP
RegEx>_,TEMP_3,0,,,1,-,UUID_3
RegEx>\.,UUID_3,0,,,1,,UUID_3
Trim>UUID_3,UUID_3
MDL>UUID_3

Let>REGISTRY_ROOT=HKEY_LOCAL_MACHINE
Let>REGISTRY_KEY=SOFTWARE\Microsoft\Cryptography
Let>REGISTRY_ENTRY=MachineGuid
If>OS_PLATFORM=WIN64
  Let>REG_64=1
Endif>
RegistryReadKey>REGISTRY_ROOT,REGISTRY_KEY,REGISTRY_ENTRY,UUID_4
UpperCase>UUID_4
Trim>UUID_4,UUID_4
MDL>UUID_4
Let>ME=%Script%

Running: 15.0.18
version history

User avatar
Marcus Tettmar
Site Admin
Posts: 7335
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Ways of getting a hardware based unique identifier

Post by Marcus Tettmar » Wed Apr 01, 2020 7:08 pm

You could also do the following, a version of which has been posted on the forum before:

Code: Select all

VBSTART
  Function GenerateUUID
    Set TypeLib = CreateObject("Scriptlet.TypeLib")
    GenerateUUID = TypeLib.Guid
  End Function
VBEND
VBEval>GenerateUUID,strUUID
Or use Python:

Code: Select all

/*
pyuid:
import uuid
res = uuid.uuid4()
*/
LabelToVar>pyuid,pyCode
PyExec>pyCode,buf,res
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7335
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Ways of getting a hardware based unique identifier

Post by Marcus Tettmar » Wed Apr 01, 2020 11:02 pm

Sorry, I realise my examples just get a unique ID, not one based on the hardware.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Grovkillen
Automation Wizard
Posts: 665
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Ways of getting a hardware based unique identifier

Post by Grovkillen » Thu Apr 02, 2020 12:39 am

Good to know though :)
Let>ME=%Script%

Running: 15.0.18
version history

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts