1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wrong prompt in Windows command console

Discussion in 'Support' started by thorsten, Jun 8, 2011.

  1. thorsten

    Joined:
    Aug 16, 2008
    Messages:
    120
    Likes Received:
    0
    Hi,

    I have set the following prompt in Advanced System Settings > Environment Variables > User variables (see attachment):

    %username%@%computername%[$p]$g$s

    When I start a cmd window via Run > Cmd [Enter], the prompt is displayed as "SYSTEM@HOMBRE[C:\Users\thorsten]> " (instead of "thorsten@HOMBRE[C:\Users\thorsten]> ", manually setting the prompt again results in the desired prompt:

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    SYSTEM@HOMBRE[C:\Users\thorsten]> set username
    USERNAME=thorsten

    SYSTEM@HOMBRE[C:\Users\thorsten]> set prompt
    prompt=SYSTEM@HOMBRE[$p]$g$s

    SYSTEM@HOMBRE[C:\Users\thorsten]> prompt %username%@%computername%[$p]$g$s

    thorsten@HOMBRE[C:\Users\thorsten]>

    My TCC prompt (set prompt=`$u@%_host[...`]) does not show the issue.

    Why does Cmd think I am "SYSTEM"?
     

    Attached Files:

  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    I might be mistaken, but I don't think CMD.EXE supports delayed expansion in the prompt.
     
  3. thorsten

    Joined:
    Aug 16, 2008
    Messages:
    120
    Likes Received:
    0
    Then why does only the %username% part not work but the %computername% does? TMP for instance is by default %USERPROFILE%\AppData\Local\Temp. Actually the same prompt works on a Windows 2008R2 machine (which is the server variant of Windows 7).

    To give a tentative answer to my question why Windows thinks I am SYSTEM: actually there is a system variable USERNAME=SYSTEM. Naturally my user variable which is dynamically set to my user name should have precedence.

    Anyway, the quick fix for my problem ist to hardcode my prompt to thorsten@%computername%. Not pretty but it works.
     
  4. thorsten

    Joined:
    Aug 16, 2008
    Messages:
    120
    Likes Received:
    0
    The fix was even simpler than to hardcode %username%: I changed the system variable USERNAME to ZZZSYSTEM (and back to SYSTEM) and it started to work
     

Share This Page