我正在創建一個批處理指紋識別器,我混合使用 SystemInfo 和 IpConfig 來為計算機獲取唯一的 sha256 哈希值,問題是我的 systeminfo 輸出有啟動時間和其他每次都會更改的內容,并且我需要一種在生成哈希之前省略它們的方法。我目前的整個代碼是:
@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
uj5u.com熱心網友回復:
感謝 Squashman 找到了答案,以防有人想使用它的最終代碼是:
@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
uj5u.com熱心網友回復:
就像幾乎所有關于您的計算機的資訊一樣,計算機的唯一識別符號可以在wmic. 在本例中,它是處理來自 SMBIOS 的計算機系統產品資訊UUID的csproduct類的屬性。
wmic資料末尾有一些額外的回車符,因此需要進行一些調整,然后才能for /f像普通命令一樣通過回圈運行它,但它看起來像這樣:
for /f "delims=" %%A in ('wmic csproduct get UUID /value ^| find "="') do set %%A
這將使wmic命令以格式輸出其資料UUID=00000000-0000-0000-0000-000000000000,然后將 UUID 設定為名為 的變數%UUID%,find用于查找=并洗掉多余的回車符。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/331358.html
