mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 11:39:16 +08:00
Add option to run as administrator for Shell plugin
This commit is contained in:
parent
b47e7f068c
commit
92bde25a49
@ -10,6 +10,7 @@ using Microsoft.Win32;
|
|||||||
using Shell;
|
using Shell;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Plugin.Program.Logger;
|
using Wox.Plugin.Program.Logger;
|
||||||
|
using Wox.Plugin.SharedCommands;
|
||||||
|
|
||||||
namespace Wox.Plugin.Program.Programs
|
namespace Wox.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
@ -96,14 +97,7 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
|
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
var info = new ProcessStartInfo
|
return Main.StartProcess(ShellCommand.SetCMDRunAsAdministrator(FullPath, ParentDirectory));
|
||||||
{
|
|
||||||
FileName = FullPath,
|
|
||||||
WorkingDirectory = ParentDirectory,
|
|
||||||
Verb = "runas"
|
|
||||||
};
|
|
||||||
var hide = Main.StartProcess(info);
|
|
||||||
return hide;
|
|
||||||
},
|
},
|
||||||
IcoPath = "Images/cmd.png"
|
IcoPath = "Images/cmd.png"
|
||||||
},
|
},
|
||||||
|
24
Wox.Plugin/SharedCommands/ShellCommand.cs
Normal file
24
Wox.Plugin/SharedCommands/ShellCommand.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.SharedCommands
|
||||||
|
{
|
||||||
|
public static class ShellCommand
|
||||||
|
{
|
||||||
|
public static ProcessStartInfo SetCMDRunAsAdministrator(this string fullPath, string parentDirectory)
|
||||||
|
{
|
||||||
|
var info = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = fullPath,
|
||||||
|
WorkingDirectory = parentDirectory,
|
||||||
|
Verb = "runas"
|
||||||
|
};
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -78,6 +78,7 @@
|
|||||||
<Compile Include="Result.cs" />
|
<Compile Include="Result.cs" />
|
||||||
<Compile Include="ActionContext.cs" />
|
<Compile Include="ActionContext.cs" />
|
||||||
<Compile Include="SharedCommands\SearchWeb.cs" />
|
<Compile Include="SharedCommands\SearchWeb.cs" />
|
||||||
|
<Compile Include="SharedCommands\ShellCommand.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
Loading…
Reference in New Issue
Block a user