mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
fixed #1267: Don't run installer as admin if member of administrators group
This commit is contained in:
parent
b47687f9fe
commit
d16dcaa9ce
2 changed files with 19 additions and 1 deletions
|
@ -1229,6 +1229,24 @@ public static bool IsAdministrator()
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsMemberOfAdministratorsGroup()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
|
||||
{
|
||||
WindowsPrincipal principal = new WindowsPrincipal(identity);
|
||||
SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
|
||||
return principal.UserClaims.Any(x => x.Value.Contains(sid.Value));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string RepeatGenerator(int count, Func<string> generator)
|
||||
{
|
||||
string result = "";
|
||||
|
|
|
@ -168,7 +168,7 @@ private void RunInstaller()
|
|||
psi.Arguments += " /VERYSILENT";
|
||||
}
|
||||
|
||||
if (Helpers.IsDefaultInstallDir())
|
||||
if (Helpers.IsDefaultInstallDir() && !Helpers.IsMemberOfAdministratorsGroup())
|
||||
{
|
||||
psi.Verb = "runas";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue