12

In Windows Vista, is there a way to remove the word 'Administrator:' from the title of a command prompt window?

The 'title' command just updates the part after 'Administrator:', so that will not do.

8 Answers 8

16

There are another two possibilities here:

  • Use the cmd.exe from Windows XP
  • Modify the MUI data for cmd.exe:

You’ll need to modify the MUI data file for cmd.exe. This file is called cmd.exe.mui, and is located in C:\Windows\System32\en-US on a standard 32-bit, United States installation. For other languages, the en-US will be different, and for 64-bit installations, you’ll need to modify both the version in System32 and in SysWOW64.

  • First off, take ownership of cmd.exe.mui. Right-click on the file, click Advanced on the security tab. On the Owner tab, click Edit, and select the Administrators account.

  • Now, give access to modify the file. Go back into the properties for the file, click Edit on the Security tab, click Add, and enter Administrators, then make sure they have the Full Control option set to Allow.

  • Using a hex editor, resource editor, or other editor of your choice, modify the string in the file from “Administrator: %0” to “ %0” (That’s two spaces before the %0, don’t forget the null character at the end).

  • Save the file

  • Run mcbuilder.exe (this could take some time to run)

  • Reboot the computer.

(from this thread - note, you can use a space, but it has to be something.)

11
  • Someone should write a tool to do this....
    – Unkwntech
    Jul 3, 2009 at 15:26
  • I choose the easy way and took a cmd.exe from XP. Thanks a lot!
    – eli
    Jul 3, 2009 at 20:28
  • It seems to work with only a single space before "%0", too. I didn't try to remove the last space, but I wouldn't be surprised if that's possible.
    – torhu
    Jan 9, 2012 at 16:21
  • On Windows 8 x64 I didn't have to run mcbuilder.exe. I found cmd.exe.mui in one of the SxS folders. Every string in there was UTF-16, so keep that in mind and remember the null bytes in your search.
    – Plynx
    Dec 30, 2012 at 10:06
  • This is an excellent answer, but it's effing annoying to have to do this. Aug 20, 2013 at 21:38
6
runas /trustlevel:0x20000 "cmd /k title My Awesome Command Prompt"
2
  • This will just run it as non-admin, right? Aug 29, 2013 at 3:13
  • This still says administrator when I try it
    – user327392
    Jan 1, 2016 at 19:58
5

While it has been proven not to solve the problem in this bug, not everyone knows you can use the title command and set the title to whatever you want it to be.

4
  • Woot! Didn't know about the "title" command. Thanks.
    – Wesley
    Jul 3, 2009 at 14:19
  • 5
    Unfortunately, it does not remove the 'Administrator:' part. I updated the question.
    – eli
    Jul 3, 2009 at 14:22
  • You don't need to down-vote useful distractions. The correct answer will be marked accepted, but there is other useful stuff to be gleamed by other answers, you know...
    – crb
    Jul 3, 2009 at 15:28
  • sorry man, somebody else voted you down. but I appreciate your effort, so I'll vote you up ;-)
    – eli
    Jul 3, 2009 at 20:16
2

Run the command prompt as a standard user (ie be logged in as a standard user).

If needed, you can always use runas to run commands as any other user including whatever adminstrative users you have.

1

I just created a simple PowerShell script that rely on a .NET class compiled at runtime to automate the steps explained in @crb answer.

This solution works for English and Spanish versions of the cmd.exe.mui file, and I made it easy to add support for more languages just by adding new entries to the dict object.

Enjoy!.

Source-Code

$source = @'
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
imports System.Diagnostics
Imports System.IO
imports System.Linq
Imports System.Text

Public NotInheritable Class MainClass

    Public Shared Sub Main()
        Dim dict As New Dictionary(Of String(), String) From {
            {{Environment.ExpandEnvironmentVariables("%SystemRoot%\System32\en-US\cmd.exe.mui"),
              Environment.ExpandEnvironmentVariables("%SystemRoot%\SysWOW64\en-US\cmd.exe.mui")},
              "Administrator: "},
            {{Environment.ExpandEnvironmentVariables("%SystemRoot%\System32\es-ES\cmd.exe.mui"),
              Environment.ExpandEnvironmentVariables("%SystemRoot%\SysWOW64\es-ES\cmd.exe.mui")},
              "Administrador: "}
        }

        For Each key As String() In dict.Keys
            For Each filepath As String In key
                If File.Exists(filepath) Then
                    Console.WriteLine(String.Format("Searching for string: '{0}' in file: '{1}'", dict(key), filepath))
                    ReplaceBytes(filepath, Encoding.GetEncoding("UTF-16").GetBytes(dict(key)), {&H81, &H0})
                End If
            Next filepath
        Next key
    End Sub

    Private Shared Sub ReplaceBytes(filepath As String, find As Byte(), replace As Byte())
        Dim buffer As Byte() = File.ReadAllBytes(filepath)
        Dim index As Integer = FindByteSequence(buffer, find, 0).DefaultIfEmpty(-1).SingleOrDefault()

        If (index <> -1) Then
            If Not File.Exists(String.Format("{0}.bak", filepath)) Then
                Console.WriteLine(String.Format("Creating backup file: '{0}.bak'", filepath))
                File.Copy(filepath, String.Format("{0}.bak", filepath), overwrite:=False)
            End If

            buffer = buffer.Take(index).Concat(replace).Concat(buffer.Skip(index + find.Length)).ToArray()

            Console.WriteLine(String.Format("Rebuilding file: '{0}'", filepath))
            Using fs As New FileStream(filepath, FileMode.Create, FileAccess.Write, FileShare.None)
                fs.Write(buffer, 0, buffer.Length)
            End Using

        Else
            Console.WriteLine(String.Format("String not found in file: '{0}'", filepath))

        End If
    End Sub

    ' Original author: https://stackoverflow.com/a/332667/1248295
    Private Shared Function FindByteSequence(buffer As Byte(), pattern As Byte(), startIndex As Integer) As ReadOnlyCollection(Of Integer)
        Dim positions As New List(Of Integer)
        Dim i As Integer = Array.IndexOf(buffer, pattern(0), startIndex)

        Do While (i >= 0) AndAlso (i <= (buffer.Length - pattern.Length))
            Dim segment(pattern.Length - 1) As Byte
            System.Buffer.BlockCopy(buffer, i, segment, 0, pattern.Length)
            If segment.SequenceEqual(pattern) Then
                positions.Add(i)
            End If
            i = Array.IndexOf(buffer, pattern(0), i + 1)
        Loop

        Return positions.AsReadOnly()
    End Function

End Class
'@ 

$vbType = Add-Type -TypeDefinition $source `
                   -CodeDomProvider (New-Object Microsoft.VisualBasic.VBCodeProvider) `
                   -PassThru `
                   -ReferencedAssemblies "Microsoft.VisualBasic.dll", `
                                         "System.dll" `
                                         | where { $_.IsPublic }

[MainClass]::Main()

$Console = [System.Console]
$Console::WriteLine("All done. Press any key to exit...")
$Console::ReadKey($true)
Exit(0)

Output

enter image description here

After the change

enter image description here

Notes:

  • Tested on Windows 10.0.18363.959 with PowerShell 5.1.18362.752

  • In @crb answer it says in a 64-Bit O.S the user needs to modify also the cmd.exe.mui file in SysWOW64 dir, however I have a 64-bit Windows 10 and that file does not exist inside SysWOW64 dir, anyways I added that path to the code in case of.

  • I didn't add any instruction to run mcbuilder.exe since I found it is not really necessary ...at least for me, the change is applied directly when opening a new instance of the CMD.

2
  • It works in PowerShell 5.1, but does not work in PowerShell 7. May 1, 2023 at 22:04
  • @ElektroStudios I don't want "Administrator:" to be completely removed, I want to show an "A" instead to still be able to differentiate elevated prompts. How to change the hex byte sequence in your code to achieve this? I tried and failed to do it on my own.
    – Robert G.
    Jun 8, 2023 at 12:06
0

Why do you want to remove it? It's there to signify that you're running an elevated command prompt as opposed to a regular command prompt.

If you've disabled the UAC then you might see this on all your command prompts as you're basically always running in elevated mode

1
  • 10
    Because I use the title command to identify the different command prompts in my task bar, and there is not enough room in the taskbar button.
    – eli
    Jul 3, 2009 at 14:26
0

I haven't tried this, but what about creating an Administrator account called "a", and then changing your CMD shortcut to be a "runas," calling CMD with "a" as the user.

That will shorten up the name so you can fit the real title nicely in the taskbar (which you indicated was your goal for doing this).

1
  • 2
    It will still show Administrator: as far as I can tell because what it tries to show is that the prompt is elevated - not which user is running it. Jul 3, 2009 at 16:20
0

I stopped using the standard cmd.exe shell, and am now using Console2 which does not have this 'administrator' problem.

1
  • That's not actually true: it has the exact same problem. Apparently it's just some kind of shallow wrapper around the built in command window and uses the title that cmd provides to it. Oct 8, 2013 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .