OpenInShellCommand.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Microsoft.CmdPal.Ext.System.Helpers; 6 using Microsoft.CommandPalette.Extensions.Toolkit; 7 8 namespace Microsoft.CmdPal.Ext.System; 9 10 public sealed partial class OpenInShellCommand : InvokableCommand 11 { 12 public OpenInShellCommand(string name, string path, string? arguments = null, string? workingDir = null, OpenInShellHelper.ShellRunAsType runAs = OpenInShellHelper.ShellRunAsType.None, bool runWithHiddenWindow = false) 13 { 14 Name = name; 15 _path = path; 16 _arguments = arguments; 17 _workingDir = workingDir; 18 _runAs = runAs; 19 _runWithHiddenWindow = runWithHiddenWindow; 20 } 21 22 public override CommandResult Invoke() 23 { 24 OpenInShellHelper.OpenInShell(_path, _arguments); 25 return CommandResult.Dismiss(); 26 } 27 28 private string _path; 29 private string? _workingDir; 30 private string? _arguments; 31 private OpenInShellHelper.ShellRunAsType _runAs; 32 private bool _runWithHiddenWindow; 33 }