Skip to content

Feature: Added shortcut to open Windows Terminal as administrator #11281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Files.App/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private async void ColumnShellPage_PreviewKeyDown(object sender, KeyRoutedEventA

switch (c: ctrl, s: shift, a: alt, t: tabInstance, k: args.Key)
{
case (true, false, false, true, (VirtualKey)192): // ctrl + ` (accent key), open terminal
case (true, _, false, true, (VirtualKey)192): // ctrl + ` (accent key), open terminal
// Check if there is a folder selected, if not use the current directory.
string path = FilesystemViewModel.WorkingDirectory;
if (SlimContentPage?.SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder)
Expand All @@ -241,9 +241,11 @@ private async void ColumnShellPage_PreviewKeyDown(object sender, KeyRoutedEventA
var terminalStartInfo = new ProcessStartInfo()
{
FileName = "wt.exe",
WorkingDirectory = path
Arguments = $"-d {path}",
Verb = shift ? "runas" : "",
UseShellExecute = true
};
Process.Start(terminalStartInfo);
DispatcherQueue.TryEnqueue(() => Process.Start(terminalStartInfo));

args.Handled = true;
break;
Expand Down
8 changes: 5 additions & 3 deletions src/Files.App/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private async void ModernShellPage_PreviewKeyDown(object sender, KeyRoutedEventA

switch (c: ctrl, s: shift, a: alt, t: tabInstance, k: args.Key)
{
case (true, false, false, true, (VirtualKey)192): // ctrl + ` (accent key), open terminal
case (true, _, false, true, (VirtualKey)192): // ctrl + ` (accent key), open terminal
// Check if there is a folder selected, if not use the current directory.
string path = FilesystemViewModel.WorkingDirectory;
if (SlimContentPage?.SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder)
Expand All @@ -226,9 +226,11 @@ private async void ModernShellPage_PreviewKeyDown(object sender, KeyRoutedEventA
var terminalStartInfo = new ProcessStartInfo()
{
FileName = "wt.exe",
WorkingDirectory = path
Arguments = $"-d {path}",
Verb = shift ? "runas" : "",
UseShellExecute = true
};
Process.Start(terminalStartInfo);
DispatcherQueue.TryEnqueue(() => Process.Start(terminalStartInfo));

break;

Expand Down