Skip to content

Commit

Permalink
Add admin permissions when non-admin doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen Tran committed May 22, 2023
1 parent c55edca commit 6cc5fe8
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -201,6 +202,21 @@ private static bool DoOpenSettingsAction(WindowsSetting entry)
Process.Start(processStartInfo);
return true;
}
catch (Win32Exception)
{
try
{
processStartInfo.UseShellExecute = true;
processStartInfo.Verb = "runas";
Process.Start(processStartInfo);
return true;
}
catch (Exception exception)
{
Log.Exception("can't open settings on elevated permission", exception, typeof(ResultHelper));
return false;
}
}
catch (Exception exception)
{
Log.Exception("can't open settings", exception, typeof(ResultHelper));
Expand Down

0 comments on commit 6cc5fe8

Please sign in to comment.