Generating a unique ID for a Windows PC

Software licensing usually works by tying a product to a single PC. Identifying the PC in a unique manner usually requires generating some kind of unique ID.

Here’s a log of certain attributes of a Windows PC (a Parallels virtual machine) read using the Windows Management Instrumentation API of .NET. It was generated using the WMI Query utility available at GitHub.

Win32_BaseBoard.Manufacturer="Parallels Software International Inc."
Win32_BaseBoard.Name="Base Board"
Win32_BIOS.Manufacturer="Parallels Software International Inc."
Win32_BIOS.SMBIOSBIOSVersion="10.2.1 (29006) rev 0"
Win32_BIOS.SerialNumber="Parallels-FC C8 89 B7 D4 BF 4E 13 9D 53 D8 BC C1 9B 90 A8"
Win32_BIOS.Version="PRLS   - 1"
Win32_Processor.Name="Intel(R) Core(TM) i7-3840QM CPU @ 2.80GHz"
Win32_OperatingSystem.Name="Microsoft Windows 8 Pro|C:\WINDOWS|\Device\Harddisk0\Partition2"

The challenge in generating a unique ID is deciding which information to use. The ID itself can be generated fairly easily by hashing the information using a cryptographic hash function.

Use too much of the information above and you risk the ID changing frequently. Updating Parallels may result in changes to Win32_BIOS.SMBIOSBIOSVersion and Win32_BIOS.ReleaseDate. Upgrading Windows may result in changes to Win32_OperatingSystem.Name, Win32_OperatingSystem.OSArchitecture, and Win32_OperatingSystem.SerialNumber.

I’ve found Win32_BIOS.SerialNumber and Win32_Processor.ProcessorId to be fairly stable. They’ll only change if the PC’s motherboard is changed or its CPU. Not likely to happen that frequently with laptops.


git stash

git stash can be a useful mechanism to set aside work you’re not ready to commit yet.

To stash staged changes simply run

git stash

Files in working directory not added to index are not affected, unless you add the -u option to stash those as well.

To view a list of stashes

git stash list

To inspect details of latest stash

git stash show stash@{0}

0 is the id shown by stash list. Use of stash@{0} is optional for latest stash entry.

To apply changes in latest stash to working directory

git stash apply

To eliminate the latest stash (use pop to apply and drop)

git stash drop

If stash apply or pop fails due to conflicts, but you still want to stage the changes, try

git checkout stash -- .

-- indicates current branch. The single dot indicates path beginning at current directory, but may be several different path specs. stash may be replaced with stash@{0}, use a different id to work with older stashes.