Add admin permissions when non-admin doesn't work

This commit is contained in:
Nguyen Tran 2023-05-21 23:39:13 -04:00
parent c55edca7cc
commit 6cc5fe8ff6

View file

@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@ -201,6 +202,21 @@ namespace Flow.Launcher.Plugin.WindowsSettings.Helper
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));