diff --git a/ShareX.HelpersLib/Helpers/Helpers.cs b/ShareX.HelpersLib/Helpers/Helpers.cs index ad4f2d34e..a18235a9b 100644 --- a/ShareX.HelpersLib/Helpers/Helpers.cs +++ b/ShareX.HelpersLib/Helpers/Helpers.cs @@ -39,6 +39,7 @@ You should have received a copy of the GNU General Public License using System.Resources; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; +using System.Security.Principal; using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -847,5 +848,10 @@ public static string GetAbsolutePath(string path) return Path.GetFullPath(path); } + + public static bool IsAdministrator() + { + return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator); + } } } \ No newline at end of file diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs index d14dd71ac..8bb77d37e 100644 --- a/ShareX/TaskHelpers.cs +++ b/ShareX/TaskHelpers.cs @@ -646,7 +646,14 @@ public static void OpenMonitorTest() public static void OpenDNSChanger() { - RunShareXAsAdmin("-dnschanger"); + if (Helpers.IsAdministrator()) + { + new DNSChangerForm().Show(); + } + else + { + RunShareXAsAdmin("-dnschanger"); + } } public static void RunShareXAsAdmin(string arguments)