From 9d1d77eb58b4b4622ea232d4cbe3171134926e85 Mon Sep 17 00:00:00 2001 From: Kaven Date: Wed, 4 Jun 2025 22:44:23 +0800 Subject: [PATCH] fix: Fixed the problem of not being able to obtain hardware information after replacing the memory stick --- lib/osinfo.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/osinfo.js b/lib/osinfo.js index e73ece8a..51c329be 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -1255,7 +1255,18 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`; } util.powerShell('Get-CimInstance Win32_ComputerSystemProduct | select UUID | fl').then((stdout) => { let lines = stdout.split('\r\n'); - result.hardware = util.getValue(lines, 'uuid', ':').toLowerCase(); + let output = '' + const windir = process.env.windir || 'C:\\Windows'; + const wmicPath = `${windir}\\System32\\wbem\\wmic.exe`; + if (fs.existsSync(wmicPath)) { + output = execSync( + `"${wmicPath}" csproduct get uuid`, + { encoding: 'utf-8' } + ).split('\n')[1] + .trim() + .toLowerCase(); + } + result.hardware = util.getValue(lines, 'uuid', ':').toLowerCase() || output; exec(`${sysdir}\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid`, util.execOptsWin, function (error, stdout) { parts = stdout.toString().split('\n\r')[0].split('REG_SZ'); result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase() : '';