diff --git a/src/MaaWpfGui/Main/Bootstrapper.cs b/src/MaaWpfGui/Main/Bootstrapper.cs index 3af91320eda..f24069e0800 100644 --- a/src/MaaWpfGui/Main/Bootstrapper.cs +++ b/src/MaaWpfGui/Main/Bootstrapper.cs @@ -15,6 +15,7 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +using System.Security.Principal; using System.Windows; using System.Windows.Threading; using GlobalHotKey; @@ -106,6 +107,10 @@ protected override void OnStart() _logger.Information("MaaAssistantArknights GUI started"); _logger.Information("Maa ENV: {MaaEnv}", maaEnv); _logger.Information("User Dir {CurrentDirectory}", Directory.GetCurrentDirectory()); + if (IsUserAdministrator()) + { + _logger.Information("Run as Administrator"); + } _logger.Information("==================================="); try @@ -134,6 +139,15 @@ protected override void OnStart() LocalizationHelper.Load(); } + private static bool IsUserAdministrator() + { + WindowsIdentity identity = WindowsIdentity.GetCurrent(); + WindowsPrincipal principal = new WindowsPrincipal(identity); + SecurityIdentifier adminSid = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null); + + return principal.IsInRole(adminSid); + } + /// protected override void ConfigureIoC(IStyletIoCBuilder builder) {