From 8b8fcd8c7b0871b49be4af85843782a4d5bf5c6a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 12 Jun 2025 16:16:58 +0800 Subject: [PATCH] Add IsAdmin --- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index a00319c79..30d96f1b2 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -47,6 +47,8 @@ namespace Flow.Launcher.Plugin.Shell Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\WindowsApps\wt.exe"), }; + private static readonly bool IsAdmin = IsAdministrator(); + private Settings _settings; public List Query(Query query) @@ -518,5 +520,12 @@ namespace Flow.Launcher.Plugin.Shell { Context.API.RemoveGlobalKeyboardCallback(API_GlobalKeyboardEvent); } + + private static bool IsAdministrator() + { + using var identity = WindowsIdentity.GetCurrent(); + var principal = new WindowsPrincipal(identity); + return principal.IsInRole(WindowsBuiltInRole.Administrator); + } } }