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:
Alekhya
2020-07-08 13:05:57 -07:00
committed by GitHub
parent 638cd1dd48
commit 411140c3ea
11 changed files with 162 additions and 40 deletions

View File

@@ -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