mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Add ability to run as a different user for win32 programs
This commit is contained in:
@@ -6,10 +6,12 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
using Shell;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin.Program.Logger;
|
||||
using Wox.Plugin.SharedCommands;
|
||||
|
||||
namespace Wox.Plugin.Program.Programs
|
||||
{
|
||||
@@ -64,7 +66,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
FileName = FullPath,
|
||||
WorkingDirectory = ParentDirectory
|
||||
};
|
||||
var hide = Main.StartProcess(info);
|
||||
var hide = Main.StartProcess(Process.Start, info);
|
||||
return hide;
|
||||
}
|
||||
};
|
||||
@@ -91,6 +93,19 @@ namespace Wox.Plugin.Program.Programs
|
||||
{
|
||||
var contextMenus = new List<Result>
|
||||
{
|
||||
new Result
|
||||
{
|
||||
Title = api.GetTranslation("wox_plugin_program_run_as_different_user"),
|
||||
Action = _ =>
|
||||
{
|
||||
var info = FullPath.SetProcessStartInfo(ParentDirectory);
|
||||
|
||||
Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info));
|
||||
|
||||
return true;
|
||||
},
|
||||
IcoPath = "Images/user.png"
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
|
||||
@@ -102,7 +117,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
WorkingDirectory = ParentDirectory,
|
||||
Verb = "runas"
|
||||
};
|
||||
var hide = Main.StartProcess(info);
|
||||
var hide = Main.StartProcess(Process.Start, info);
|
||||
return hide;
|
||||
},
|
||||
IcoPath = "Images/cmd.png"
|
||||
@@ -112,7 +127,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
|
||||
Action = _ =>
|
||||
{
|
||||
var hide = Main.StartProcess(new ProcessStartInfo(ParentDirectory));
|
||||
var hide = Main.StartProcess(Process.Start, new ProcessStartInfo(ParentDirectory));
|
||||
return hide;
|
||||
},
|
||||
IcoPath = "Images/folder.png"
|
||||
|
||||
Reference in New Issue
Block a user