From 26ae2aa8e588d698a47da796760094b4f8a974dc Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Mon, 13 Oct 2025 19:34:45 -0300 Subject: [PATCH] =?UTF-8?q?Corrige=20detec=C3=A7=C3=A3o=20de=20ativa=C3=A7?= =?UTF-8?q?=C3=A3o=20do=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop/src-tauri/src/agent.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src-tauri/src/agent.rs b/apps/desktop/src-tauri/src/agent.rs index d76e260..0b4d369 100644 --- a/apps/desktop/src-tauri/src/agent.rs +++ b/apps/desktop/src-tauri/src/agent.rs @@ -693,8 +693,10 @@ fn collect_windows_extended() -> serde_json::Value { // Informações de build/edição e ativação let os_info = ps(r#" $cv = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'; - $ls = Get-CimInstance -Query "SELECT Name, LicenseStatus FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL" | Where-Object { $_.Name -like 'Windows*' } | Select-Object -First 1; - $lsCode = if ($ls -and $ls.LicenseStatus -ne $null) { [int]$ls.LicenseStatus } else { 0 }; + $lsItems = Get-CimInstance -Query "SELECT Name, LicenseStatus, PartialProductKey FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL" | Where-Object { $_.Name -like 'Windows*' }; + $activatedItem = $lsItems | Where-Object { $_.LicenseStatus -eq 1 } | Select-Object -First 1; + $primaryItem = if ($activatedItem) { $activatedItem } else { $lsItems | Select-Object -First 1 }; + $lsCode = if ($primaryItem -and $primaryItem.LicenseStatus -ne $null) { [int]$primaryItem.LicenseStatus } else { 0 }; [PSCustomObject]@{ ProductName = $cv.ProductName CurrentBuild = $cv.CurrentBuild @@ -703,7 +705,7 @@ fn collect_windows_extended() -> serde_json::Value { ReleaseId = $cv.ReleaseId EditionID = $cv.EditionID LicenseStatus = $lsCode - IsActivated = ($lsCode -eq 1) + IsActivated = ($activatedItem -ne $null) } "#).unwrap_or_else(|| json!({}));