Merge pull request #2149 from ngtr6788/windows-settings-elevation

Fix: Add admin permissions when non-admin doesn't work
This commit is contained in:
Kevin Zhang 2023-05-26 16:15:25 +08:00 committed by GitHub
commit 414482975d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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));