Files
PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs
Michael Jolley 19390e3198 Users can now pin/unpin apps from the top of AllApps extension (#40544)
Users can now use Ctrl+P to toggle pinning and unpinning applications
from the top of the All Apps extension.

This pinned status persists through restarts & reboots.


https://github.com/user-attachments/assets/86895a38-7312-438a-9409-b50a85979d12

Reference: #40543

---------

Co-authored-by: Mike Griese <migrie@microsoft.com>
2025-07-15 08:59:32 -05:00

55 lines
1.4 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 ManagedCommon;
using Microsoft.CmdPal.Ext.Apps.Helpers;
using Microsoft.CmdPal.Ext.Apps.Properties;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.Apps.Commands;
internal sealed partial class OpenInConsoleCommand : InvokableCommand
{
private readonly string _target;
public OpenInConsoleCommand(string target)
{
Name = Resources.open_path_in_console;
Icon = Icons.OpenConsoleIcon;
_target = target;
}
internal static async Task LaunchTarget(string t)
{
await Task.Run(() =>
{
try
{
var processStartInfo = new ProcessStartInfo
{
WorkingDirectory = t,
FileName = "cmd.exe",
};
Process.Start(processStartInfo);
}
catch (Exception ex)
{
Logger.LogError(ex.Message);
}
});
}
public override CommandResult Invoke()
{
_ = LaunchTarget(_target).ConfigureAwait(false);
return CommandResult.Dismiss();
}
}