Like with cmd.exe or PowerShell, you often have to run Windows Terminal as admin to execute commands that need elevated privileges. In Windows Terminal, you can configure the elevation of privileges for an individual shell or for all shells. However, you have to expect some inconsistencies and peculiarities.
Avatar

Unlike the traditional console host, Windows Terminal runs the various command lines in tabs, with each shell configured through its own profile.

A profile's settings also include the option to run the respective shell with elevated privileges. However, by default, Windows Terminal opens all predefined profiles in the context of the currently logged-in account.

Create an administrative profile

To configure a new shell for administrative purposes, you can use the function to duplicate existing profiles. To do so, open the settings and click Add a new profile.

Create a new administrative profile based on an existing one

Create a new administrative profile based on an existing one

In the following dialog box, select an existing profile that you want to copy, and execute the Duplicate command. Now the settings of this new profile open, and you can change its name and activate the Run this profile as Administrator option.

Name the cloned profile and configure it to run as admin

Name the cloned profile and configure it to run as admin

After being saved, this new profile appears immediately on the dropdown list and can be started directly. As expected, the following authentication expects you to enter the credentials of an administrative account.

The new administrative profile can be started from the list of all shells

The new administrative profile can be started from the list of all shells

Separate windows for admin shells

After you have successfully logged in, the command line does not open in a new tab but in a separate window. This is not entirely surprising, because the program in question is started as a child process of the terminal.

All administrative account profiles open in their own window

All administrative account profiles open in their own window

However, if you open another instance of the administrative shell, it does not appear as a tab in the existing admin terminal, but again in a separate window.

Run all shells as admin

If you want to use Windows Terminal only for administrative purposes, you can activate the Run this profile as Administrator option in the settings under Profiles > Defaults. This saves you the effort of launching the terminal as an administrator. Since the icon in the taskbar does not offer this option, you would have to use the search function as a workaround.

Run all shells as admin by configuring the default values

Run all shells as admin by configuring the default values

Another quirk of Windows Terminal is that it opens all shells with elevated privileges at the next startup if you have selected the admin option for the default profile. Usually, this is Windows PowerShell. You will then no longer be able to access the original user's settings to undo this change (other than by editing the JSON file).

Error when opening in an admin context

Windows Terminal is a Store app, and as such, requires installation for each user. Depending on how the terminal was installed on your machine, running it as an administrator may fail if it doesn't exist for the account in question.

If you download the program from the store, the store app sets up the Windows terminal for all users. If, on the other hand, you install it under a standard account via sideloading of the MSIX bundle, then it is missing in the profile of the administrative account and, accordingly, causes an error message if you try to start a profile with elevated rights.

If Windows Terminal was not installed for the admin the privileged shell will fail to run

If Windows Terminal was not installed for the admin the privileged shell will fail to run

In this case, the additional installation of Windows Terminal under the privileged user usually helps. However, with some previews of Windows 11, running a profile as admin may fail even then.

Conclusion

Executing command lines in tabs of a single terminal window is convenient, but it makes launching shells with elevated privileges more complicated. Windows Terminal provides a corresponding option for each individual profile or for all shells.

If you decide to configure individual profiles for elevating permissions, they always open a separate window, which actually contradicts the concept of the application.

Subscribe to 4sysops newsletter!

The questionable decision to implement Windows Terminal as a Store app has also proven to be an obstacle. Depending on how the tool was installed, the invocation as admin may fail.

avataravatar
3 Comments
  1. Avatar

    Great post as usual. Thank you for sharing the useful trick Mr. Wolfgang.

  2. Avatar
    iamqiz 1 year ago

    good job,thanks!

  3. Avatar
    peter 6 months ago

    Hi, I was playing with the terminal and got stuck in the admin mode that you mentioned in one paragraph. How can I disabled the terminal to open always as admin using the JSON?

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account