mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Add run as admin context menu item for application results returned by the Indexer Plugin (#4807)
* Added run as admin context menu item to apps returned by indexer plugin * Added a test and localized strings * localize strings * Add more tests for folder and other file types * fixed run as admin -> run as administrator * resolved merge conflict * refactored tests * moved common code to helper and added logs * moved start process to the helper class * added more info in a comment * fixed count in tests as open in console was added * removed additional code that was added while fixing merge conflicts
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
@@ -76,6 +77,26 @@ namespace Wox.Infrastructure
|
||||
return formatted;
|
||||
}
|
||||
|
||||
// Function to run as admin for context menu items
|
||||
public static void RunAsAdmin(string path)
|
||||
{
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = path,
|
||||
WorkingDirectory = Path.GetDirectoryName(path),
|
||||
Verb = "runas",
|
||||
UseShellExecute = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(info);
|
||||
}
|
||||
catch(System.Exception ex)
|
||||
{
|
||||
Log.Exception($"Wox.Infrastructure.Helper| Unable to Run {path} as admin : {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
public static Process OpenInConsole(string path)
|
||||
{
|
||||
var processStartInfo = new ProcessStartInfo
|
||||
|
||||
Reference in New Issue
Block a user