11

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.

eli
  • 213
  • 1
  • 2
  • 7

8 Answers8

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.)

crb
  • 7,998
  • 1
  • 38
  • 53
  • Someone should write a tool to do this.... – Unkwntech Jul 03 '09 at 15:26
  • I choose the easy way and took a cmd.exe from XP. Thanks a lot! – eli Jul 03 '09 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 09 '12 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 '12 at 10:06
  • This is an excellent answer, but it's effing annoying to have to do this. – Camilo Martin Aug 20 '13 at 21:38
  • I just wanted to comment on how I did it: Edited the string with a hex editor, re-built the MUI(DLL)'s MD5 with CFF Explorer, and didn't have to run mcbuilder (Win7 x64). Plus, I could get away with no spaces at all. – Camilo Martin Aug 30 '13 at 20:15
  • I did not make any change to the files at `SysWOW64` on my Windows 7 Ultimate 64 bits and my admin console seems to be working OK with my preferred title. – Sopalajo de Arrierez May 17 '15 at 15:41
  • For some reason Windows (10 Pro x64 1809) didn't allow me to change the original file, even after changing permissions. However I could rename it and place its patched copy in its place. – thorn Mar 15 '19 at 18:42
  • On Windows 10 1903, there is no `cmd.exe.mui` anymore. Where does this string come from now? – thorn Nov 29 '19 at 10:59
  • For a Spanish O.S the hex data is: "41 00 64 00 6D 00 69 00 6E 00 69 00 73 00 74 00 72 00 61 00 64 00 6F 00 72 00 3A 00 20 00 25 00 30" ("A.d.m.i.n.i.s.t.r.a.d.o.r.:. .%.0") – ElektroStudios Dec 24 '20 at 18:50
  • I published a new answer in this thread that automates everything via PowerShell. Enjoy!. – ElektroStudios Dec 25 '20 at 14:53
6
runas /trustlevel:0x20000 "cmd /k title My Awesome Command Prompt"
Douglas Crews
  • 61
  • 1
  • 1
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.

crb
  • 7,998
  • 1
  • 38
  • 53
  • Woot! Didn't know about the "title" command. Thanks. – Wesley Jul 03 '09 at 14:19
  • 5
    Unfortunately, it does not remove the 'Administrator:' part. I updated the question. – eli Jul 03 '09 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 03 '09 at 15:28
  • sorry man, somebody else voted you down. but I appreciate your effort, so I'll vote you up ;-) – eli Jul 03 '09 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.

Oskar Duveborn
  • 10,760
  • 3
  • 33
  • 48
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.

  • It works in PowerShell 5.1, but does not work in PowerShell 7. – Dmitrii Fediuk May 01 '23 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 08 '23 at 12:06
0

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

eli
  • 213
  • 1
  • 2
  • 7
  • 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. – brianmearns Oct 08 '13 at 16:58
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

Paxxi
  • 163
  • 3
  • 8
  • 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 03 '09 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).

Adam Brand
  • 6,127
  • 2
  • 30
  • 40
  • 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. – Oskar Duveborn Jul 03 '09 at 16:20