I'm creating a batch fingerprinter, and I'm using a mix of SystemInfo and IpConfig to get a unique sha256 hash for a computer, the problem is i the systeminfo output there are things like boot time and others that change every time, and i need a way of omitting them before i generate the hash. my current whole code is:
@echo off
systeminfo >>fingerprint.txt
echo - - - - - - - - - - - - >> fingerprint.txt
ipconfig >>fingerprint.txt
:: Here i want to have the omitter
powershell Get-FileHash fingerprint.txt -Algorithm SHA256 > comphash.txt
pause
CodePudding user response:
Found an answer thanks to Squashman, final code in case someone wants to use it is:
@echo off
color 33
systeminfo | find "Domain:" /v | find "System" /v | find "Virtual" /v | find "Available" /v >> fingerprint.txt
echo Your computers unique fingerprint: >> finalhash.txt
powershell Get-FileHash fingerprint.txt -Algorithm SHA256 >> finalhash.txt
del fingerprint.txt
start finalhash.txt
pause
CodePudding user response:
Like pretty much all information about your computer, the computer's unique identifier can be found in wmic
. In this case, it's the UUID
property of the csproduct
class, which handles computer system product information from SMBIOS.
wmic
has some extra carriage returns at the end of the data so there's a bit of tweaking that needs to be done before you can just run it through a for /f
loop like a normal command, but it will look like this:
for /f "delims=" %%A in ('wmic csproduct get UUID /value ^| find "="') do set %%A
This will have the wmic
command output its data in the format UUID=00000000-0000-0000-0000-000000000000
and then set the UUID to a variable called %UUID%
, using find
to look for the =
and removing the excess carriage returns.