From 07b6f6e36e575601ec399b0ca35dd656fda8b477 Mon Sep 17 00:00:00 2001 From: Bartosz Cichecki Date: Mon, 6 Dec 2021 09:13:02 +0100 Subject: [PATCH] Reverted to switching powerplans with powercfg. --- LenovoLegionToolkit.Lib/Utils/Power.cs | 16 +++++++++++----- .../LenovoLegionToolkit.WPF.csproj | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/LenovoLegionToolkit.Lib/Utils/Power.cs b/LenovoLegionToolkit.Lib/Utils/Power.cs index 8c71ced0b4..894d11bf09 100644 --- a/LenovoLegionToolkit.Lib/Utils/Power.cs +++ b/LenovoLegionToolkit.Lib/Utils/Power.cs @@ -11,6 +11,16 @@ public class PowerPlan public string Name { get; } public bool IsActive { get; } + public string Guid + { + get + { + var guid = InstanceID.Split("\\").Last(); + guid = guid.Replace("{", "").Replace("}", ""); + return guid; + } + } + public PowerPlan(string instanceID, string name, bool isActive) { InstanceID = instanceID; @@ -41,11 +51,7 @@ public static void ActivatePowerPlan(PowerModeState powerModeState) if (powerPlan == null || powerPlan.IsActive) return; - WMI.Invoke("root\\CIMV2\\power", - "Win32_PowerPlan", - "InstanceID", - powerPlan.InstanceID, - "Activate"); + CMD.ExecuteProcess("powercfg", $"/s {powerPlan.Guid}"); } private static PowerPlan Create(PropertyDataCollection properties) diff --git a/LenovoLegionToolkit.WPF/LenovoLegionToolkit.WPF.csproj b/LenovoLegionToolkit.WPF/LenovoLegionToolkit.WPF.csproj index 6af0d6f548..8044fdfd5f 100644 --- a/LenovoLegionToolkit.WPF/LenovoLegionToolkit.WPF.csproj +++ b/LenovoLegionToolkit.WPF/LenovoLegionToolkit.WPF.csproj @@ -6,8 +6,8 @@ icon.ico Lenovo Legion Toolkit © 2021 Bartosz Cichecki - 1.5.1 - 1.5.1 + 1.5.2 + 1.5.2 disable true false