mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[DSC]Use registry instead of WMI to improve detection performance(#32382)
This commit is contained in:
committed by
GitHub
parent
07b5e1fd06
commit
6c78fdbea3
@@ -6,7 +6,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using static PowerToys.Settings.DSC.Schema.Introspection;
|
using static PowerToys.Settings.DSC.Schema.Introspection;
|
||||||
|
|
||||||
namespace PowerToys.Settings.DSC.Schema;
|
namespace PowerToys.Settings.DSC.Schema;
|
||||||
@@ -254,7 +253,12 @@ class {{module.Name}} {
|
|||||||
if ($this.Debug -eq $true) {
|
if ($this.Debug -eq $true) {
|
||||||
$SettingsExePath = "{{debugSettingsPath}}"
|
$SettingsExePath = "{{debugSettingsPath}}"
|
||||||
} else {
|
} else {
|
||||||
$installation = Get-CimInstance Win32_Product | Where-Object {$_.Name -eq "PowerToys (Preview)" -and $_.Version -eq "{{version}}"}
|
$installation = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | ForEach-Object { Get-ItemProperty $_.PsPath } | Where-Object { $_.DisplayName -eq "PowerToys (Preview)" -and $_.DisplayVersion -eq "{{version}}" }
|
||||||
|
|
||||||
|
if (-not $installation)
|
||||||
|
{
|
||||||
|
$installation = Get-ChildItem HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | ForEach-Object { Get-ItemProperty $_.PsPath } | Where-Object { $_.DisplayName -eq "PowerToys (Preview)" -and $_.DisplayVersion -eq "{{version}}" }
|
||||||
|
}
|
||||||
|
|
||||||
if ($installation) {
|
if ($installation) {
|
||||||
$SettingsExePath = Join-Path (Join-Path $installation.InstallLocation WinUI3Apps) PowerToys.Settings.exe
|
$SettingsExePath = Join-Path (Join-Path $installation.InstallLocation WinUI3Apps) PowerToys.Settings.exe
|
||||||
@@ -271,7 +275,12 @@ class {{module.Name}} {
|
|||||||
#else
|
#else
|
||||||
outputResult += $$"""
|
outputResult += $$"""
|
||||||
[string] GetPowerToysSettingsPath() {
|
[string] GetPowerToysSettingsPath() {
|
||||||
$installation = Get-CimInstance Win32_Product | Where-Object {$_.Name -eq "PowerToys (Preview)" -and $_.Version -eq "{{version}}"}
|
$installation = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | ForEach-Object { Get-ItemProperty $_.PsPath } | Where-Object { $_.DisplayName -eq "PowerToys (Preview)" -and $_.DisplayVersion -eq "{{version}}" }
|
||||||
|
|
||||||
|
if (-not $installation)
|
||||||
|
{
|
||||||
|
$installation = Get-ChildItem HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | ForEach-Object { Get-ItemProperty $_.PsPath } | Where-Object { $_.DisplayName -eq "PowerToys (Preview)" -and $_.DisplayVersion -eq "{{version}}" }
|
||||||
|
}
|
||||||
|
|
||||||
if ($installation) {
|
if ($installation) {
|
||||||
$SettingsExePath = Join-Path (Join-Path $installation.InstallLocation WinUI3Apps) PowerToys.Settings.exe
|
$SettingsExePath = Join-Path (Join-Path $installation.InstallLocation WinUI3Apps) PowerToys.Settings.exe
|
||||||
|
|||||||
Reference in New Issue
Block a user