mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01:00
Just standardizing built-in extensions to use a `internal sealed class Icons` for all their non-dynamic icons. Looks like a LOT of changes, but it's icons all the way down.
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.CmdPal.Ext.Apps.Properties;
|
|
using Microsoft.CmdPal.Ext.Apps.Utils;
|
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
namespace Microsoft.CmdPal.Ext.Apps.Commands;
|
|
|
|
internal sealed partial class RunAsUserCommand : InvokableCommand
|
|
{
|
|
private readonly string _target;
|
|
private readonly string _parentDir;
|
|
|
|
public RunAsUserCommand(string target, string parentDir)
|
|
{
|
|
Name = Resources.run_as_different_user;
|
|
Icon = Icons.RunAsUserIcon;
|
|
|
|
_target = target;
|
|
_parentDir = parentDir;
|
|
}
|
|
|
|
internal static async Task RunAsUser(string target, string parentDir)
|
|
{
|
|
await Task.Run(() =>
|
|
{
|
|
var info = ShellCommand.GetProcessStartInfo(target, parentDir, string.Empty, ShellCommand.RunAsType.OtherUser);
|
|
|
|
Process.Start(info);
|
|
});
|
|
}
|
|
|
|
public override CommandResult Invoke()
|
|
{
|
|
_ = RunAsUser(_target, _parentDir).ConfigureAwait(false);
|
|
|
|
return CommandResult.Dismiss();
|
|
}
|
|
}
|