Add a setting to remove the "Administrator:" prefix from tab titles #1315

Closed
opened 2026-01-30 22:22:20 +00:00 by claunia · 15 comments
Owner

Originally created by @DJackman123 on GitHub (May 24, 2019).

Summary of the new feature/enhancement

When I run Terminal as administrator, every tab has "Administrator:" added as a prefix to the (already long) title. I know it's running as administrator and (at least for now) all the tabs are admin sessions. I want the tab titles to be as short as possible so I can see more at once. Being able to remove this administrator prefix will help me do that.

Proposed technical implementation details (optional)

Originally created by @DJackman123 on GitHub (May 24, 2019). # Summary of the new feature/enhancement When I run Terminal as administrator, every tab has "Administrator:" added as a prefix to the (already long) title. I know it's running as administrator and (at least for now) all the tabs are admin sessions. I want the tab titles to be as short as possible so I can see more at once. Being able to remove this administrator prefix will help me do that. # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. -->
claunia added the Issue-QuestionResolution-AnsweredArea-UserInterfaceProduct-Meta labels 2026-01-30 22:22:21 +00:00
Author
Owner

@zadjii-msft commented on GitHub (May 24, 2019):

Yea, there's gonna be like no way to do this without setting custom title overrides (#608). The "Administrator: " text comes from both cmd.exe and powershell.exe, not from the Terminal itself. Note that it goes away if you open a WSL shell, because linux shells don't display "Administrator" in the title.

As far as I'm aware, you can't tell cmd.exe to not display that text when running elevated.

It's entirely possible that there's a way to tell powershell to not display that text, though I don't know enough about powershell to know for sure. Summoning @adiviness and @DHowett-MSFT

@zadjii-msft commented on GitHub (May 24, 2019): Yea, there's gonna be like no way to do this without setting custom title overrides (#608). The "Administrator: " text comes from both cmd.exe and powershell.exe, not from the Terminal itself. Note that it goes away if you open a WSL shell, because linux shells don't display "Administrator" in the title. As far as I'm aware, you can't tell cmd.exe to _not_ display that text when running elevated. It's entirely possible that there's a way to tell powershell to not display that text, though I don't know enough about powershell to know for sure. Summoning @adiviness and @DHowett-MSFT
Author
Owner

@adiviness commented on GitHub (May 24, 2019):

powershell lets you have a custom prompt, I presume that you could change the title from within that function.

@adiviness commented on GitHub (May 24, 2019): powershell lets you have a custom prompt, I presume that you could change the title from within that function.
Author
Owner

@binarycrusader commented on GitHub (May 24, 2019):

cmd has the "title" command but even that doesn't let you override the Administrator text. Personally, I understand the security implications and why it might be undesirable.

@binarycrusader commented on GitHub (May 24, 2019): cmd has the "title" command but even that doesn't let you override the Administrator text. Personally, I understand the security implications and why it might be undesirable.
Author
Owner

@oising commented on GitHub (May 24, 2019):

@djackman123 A quick way to remove the prefix for powershell is to put the following into your profile.ps1 file (learn more with get-help about_profiles | more):

[console]::title = [console]::title.replace("Administrator:", "")

For cmd shells, it's a little more involved, and when I say a "little," I mean downright unreasonably difficult to do. There is no direct way to alter the console title from batch, and only by emitting VT sequences can you change it - even then, you can only effect a permanent change to it interactively. When you run a batch file, or another process, the current window title is pushed (saved) onto a stack and then changed to reflect the running process/command, and then popped (restored) when your command/batch is done. An example -- run the following commands in powershell to create a batch file that changes the window title:

echo "@echo.`e]2;new title`a" > init.cmd
echo "@pause" >> init.cmd 

Now open a cmd shell, and run init.cmd. You'll see the title change, but it will restored once you press a key. This is already a blocker and we haven't even tried to read the current title yet to remove the prefix (like we do in powershell.)

Incidentally, if you wanted to emulate the above script using pure batch without a dependency on powershell's handy syntax for non-printable characters, it looks like this - hold onto your lunch:

settitle.cmd

@echo off & setlocal & setlocal enabledelayedexpansion
if "%1" == "" goto error
set TABNAME=%*
for /f "tokens=* delims=" %%a in ('forfiles /p %~dps0 /m %~nxs0 /c "cmd /c echo.0x1B0x07"') do @set arrChar=%%a
set ESC=!arrChar:~0,1!
set BEL=!arrChar:~1,1!
echo.%ESC%]0;%TABNAME%%BEL%
pause
goto end
:error
echo usage: title tabname
:end

Why so horrifying? Because the only way to get ESC and BEL natively in batch is to translate the hex ascii equivalents using forfiles.exe, and then capture into a variable.

TL;DR -- easy to do in powershell. Hard or impossible to do in cmd. This needs support in the terminal, conhost and the VT engine. Worst case? It needs a change directly in cmd.exe (and this ain't never gonna happen.)

@oising commented on GitHub (May 24, 2019): @djackman123 A quick way to remove the prefix for powershell is to put the following into your profile.ps1 file (learn more with `get-help about_profiles | more`): `[console]::title = [console]::title.replace("Administrator:", "")` For cmd shells, it's a little more involved, and when I say a "little," I mean downright unreasonably difficult to do. There is no direct way to alter the console title from batch, and only by emitting VT sequences can you change it - even then, you can only effect a permanent change to it *interactively*. When you run a batch file, or another process, the current window title is pushed (saved) onto a stack and then changed to reflect the running process/command, and then popped (restored) when your command/batch is done. An example -- run the following commands in powershell to create a batch file that changes the window title: ```powershell echo "@echo.`e]2;new title`a" > init.cmd echo "@pause" >> init.cmd ``` Now open a cmd shell, and run `init.cmd`. You'll see the title change, but it will restored once you press a key. This is already a blocker and we haven't even tried to read the current title yet to remove the prefix (like we do in powershell.) Incidentally, if you wanted to emulate the above script using pure batch without a dependency on powershell's handy syntax for non-printable characters, it looks like this - hold onto your lunch: **settitle.cmd** ```cmd @echo off & setlocal & setlocal enabledelayedexpansion if "%1" == "" goto error set TABNAME=%* for /f "tokens=* delims=" %%a in ('forfiles /p %~dps0 /m %~nxs0 /c "cmd /c echo.0x1B0x07"') do @set arrChar=%%a set ESC=!arrChar:~0,1! set BEL=!arrChar:~1,1! echo.%ESC%]0;%TABNAME%%BEL% pause goto end :error echo usage: title tabname :end ``` Why so horrifying? Because the only way to get ESC and BEL natively in batch is to translate the hex ascii equivalents using forfiles.exe, and then capture into a variable. TL;DR -- easy to do in powershell. Hard or impossible to do in cmd. This needs support in the terminal, conhost and the VT engine. Worst case? It needs a change directly in cmd.exe (and this ain't never gonna happen.)
Author
Owner

@DHowett-MSFT commented on GitHub (May 24, 2019):

There is no direct way to alter the console title from batch
TL;DR -- easy to do in powershell. Hard or impossible to do in cmd.

Well, admittedly, there is the title command ... but it doesn't stomp the Administrator: because it's a CMD builtin and CMD thinks it knows better than you.

image

@DHowett-MSFT commented on GitHub (May 24, 2019): > There is no direct way to alter the console title from batch > TL;DR -- easy to do in powershell. Hard or impossible to do in cmd. Well, admittedly, there is the `title` command ... but it doesn't stomp the `Administrator:` because it's a CMD builtin and CMD thinks it knows better than you. ![image](https://user-images.githubusercontent.com/14316954/58347059-afc55600-7e11-11e9-8f7e-cf350aaa7727.png)
Author
Owner

@mdtauk commented on GitHub (May 24, 2019):

When/If a statusbar is added to Windows Terminal - the "Administrator" text could be displayed there instead of taking up valuable space in the Tab itself. I don't think it is a good idea to omit any indicator to identify the window as being elevated - for security peace of mind.

For Ubuntu, the statusbar could display the current user or sudo when the prompt is of higher privilege.

@mdtauk commented on GitHub (May 24, 2019): When/If a statusbar is added to Windows Terminal - the "Administrator" text could be displayed there instead of taking up valuable space in the Tab itself. I don't think it is a good idea to omit any indicator to identify the window as being elevated - for security peace of mind. For Ubuntu, the statusbar could display the current user or **sudo** when the prompt is of higher privilege.
Author
Owner

@DHowett-MSFT commented on GitHub (May 24, 2019):

@mdtauk I'm not saying it isn't doable, but as a consumer of only standard virtual terminal sequences there is no non-heuristic way for Terminal to detect anything about the connected client. Administrator context on Windows is a little easier because we can guess based on how we started it, but anything else is a non-starter.

@DHowett-MSFT commented on GitHub (May 24, 2019): @mdtauk I'm not saying it isn't _doable_, but as a consumer of only standard virtual terminal sequences there is no non-heuristic way for Terminal to detect _anything about the connected client_. Administrator context on Windows is a little easier because we can guess based on how we started it, but anything else is a non-starter.
Author
Owner

@DHowett-MSFT commented on GitHub (May 24, 2019):

This is my primary argument against a status bar, honestly. There's nothing from the client application you can put in it that isn't guessed off a heuristic (user, computer) or simply unknowable (codepage?) to a terminal emulator.

@DHowett-MSFT commented on GitHub (May 24, 2019): This is my primary argument against a status bar, honestly. There's nothing from the client application you can put in it that isn't guessed off a heuristic (user, computer) or simply unknowable (codepage?) to a terminal emulator.
Author
Owner

@mdtauk commented on GitHub (May 24, 2019):

Sounds like an API that should be there. Something like:

Microsoft.UI.ApplicationModel.IsCurrentlyElevated

@mdtauk commented on GitHub (May 24, 2019): Sounds like an API that should be there. Something like: Microsoft.UI.ApplicationModel.IsCurrentlyElevated
Author
Owner

@DHowett-MSFT commented on GitHub (May 24, 2019):

Yes, that would solve exactly one half of one of the problems I listed. It is, unfortunately, the half that’s already solvable by some other existing means.

@DHowett-MSFT commented on GitHub (May 24, 2019): Yes, that would solve exactly one half of one of the problems I listed. It is, unfortunately, the half that’s already solvable by some other existing means.
Author
Owner

@mdtauk commented on GitHub (May 24, 2019):

Yes, that would solve exactly one half of one of the problems I listed. It is, unfortunately, the half that’s already solvable by some other existing means.

I took my inspiration for the statusbar contents from the teaser. So I assumed these were on the ToDo list.

image

@mdtauk commented on GitHub (May 24, 2019): > Yes, that would solve exactly one half of one of the problems I listed. It is, unfortunately, the half that’s already solvable by some other existing means. I took my inspiration for the statusbar contents from the teaser. So I assumed these were on the ToDo list. ![image](https://user-images.githubusercontent.com/7389110/58348897-c7c0c800-7e59-11e9-8190-ef5ae92ae1ce.png)
Author
Owner

@oising commented on GitHub (May 24, 2019):

@DHowett-MSFT Lordy, I forgot about TITLE. I remember using it in 4DOS and 4NT back in the day. Anyway, I guess it doesn't do the trick either as you say.

@oising commented on GitHub (May 24, 2019): @DHowett-MSFT Lordy, I forgot about TITLE. I remember using it in 4DOS and 4NT back in the day. Anyway, I guess it doesn't do the trick either as you say.
Author
Owner

@DHowett-MSFT commented on GitHub (May 28, 2019):

This will be better served by #608.

@DHowett-MSFT commented on GitHub (May 28, 2019): This will be better served by #608.
Author
Owner

@ElektroStudios commented on GitHub (Dec 26, 2020):

As far as I'm aware, you can't tell cmd.exe to not display that text when running elevated.

There is an approach modifying the cmd.exe.mui file:

https://serverfault.com/questions/35561/how-to-remove-administrator-from-the-command-promt-title/1047538#1047538

But the powershell.exe.mui comes more difficult to hack for me. My knowledge is limited.

@ElektroStudios commented on GitHub (Dec 26, 2020): > As far as I'm aware, you can't tell cmd.exe to _not_ display that text when running elevated. There is an approach modifying the **cmd.exe.mui** file: https://serverfault.com/questions/35561/how-to-remove-administrator-from-the-command-promt-title/1047538#1047538 ![](https://i.stack.imgur.com/bK7v4.png) ![](https://i.stack.imgur.com/6ZjN7.png) But the **powershell.exe.mui** comes more difficult to hack for me. My knowledge is limited.
Author
Owner

@trallnag commented on GitHub (Oct 20, 2021):

For PowerShell I came across this command:

$host.ui.RawUI.WindowTitle = “Changed Title”

Source: https://devblogs.microsoft.com/scripting/powertip-change-the-powershell-console-title/

So if the prefix is really bugging someone you can use this snippet to strip out the prefix.

@trallnag commented on GitHub (Oct 20, 2021): For PowerShell I came across this command: $host.ui.RawUI.WindowTitle = “Changed Title” Source: <https://devblogs.microsoft.com/scripting/powertip-change-the-powershell-console-title/> So if the prefix is really bugging someone you can use this snippet to strip out the prefix.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1315