Changes the Windows command prompt.


To change the command prompt:

PROMPT [text]

textAny series of alphanumeric characters including the following special codes:

 $P Current drive and path  $E Escape code (ASCII code 27)
 $N Current drive  $G >
 $V Windows version number  $L <
 $D Current date  $B |
 $T Current time  $Q =
 $_ Carriage return and linefeed  $$ $
 $H Backspace (erases previous character)

To reset the prompt to its default ($N$G):



  • Apart from being a recognized command, PROMPT is also one of the "Standard" environmental variables (see SET). Issuing a PROMPT command is exactly equivalent to issuing a SET command for the environmental variable prompt. ie.

    PROMPT $P$G is exactly equivalent to
    SET prompt=$P$G

    When Win95 loads, it automatically sets the prompt environment variable to $P$G - ie. Current path and ">" - and this is the prompt that most users will consider the default and expect to see:


    HOWEVER,'s default is $N$G - ie. Current drive and ">".
    This can cause some confusion with the unwary who might enter PROMPT (equivalent to resetting the environmental variable or entering: SET prompt= ) to reset the prompt after experimenting with different styles and wonder why they not only appear to have been returned to the root directory, but that CD seems not to work any more!

  • The "$E" code is used with ANSI.SYS escape sequences. These can be used to significantly add to the potential for customising the prompt, change the screen colours, or even remap some of the keys (see "Examples" below)
  • Although there is a limit of 128 characters for command line entries, long and complex prompts can be prepared by breaking the command into parts and assembling the whole using a series of PROMPT commands. Each instance of PROMPT (after the first) would include %prompt% - the environmental variable containing the current prompt string.
  • If PROMPT is used with Ansi.sys via the $e special character, changing or resetting the prompt will not reset the Ansi.sys part unless done so explicitly. In other words, colour changes and key reassignments stay in effect until explicitly changed or Dos is closed. It is thus possible to use Prompt to reassign many keys using a series of PROMPT statements.


  1. As a reminder to occasional users of Dos in Win95, the following statement could be included in Autoexec.bat:

    PROMPT Use Alt-Enter to switch from full screen to window$_$P$G

    which would display as:

    Use Alt-Enter to switch from full screen to window


  2. Using the added enhancements available if ANSI.SYS is loaded, the above prompt can be modified so that the message remains at the top of the screen (As this coding is somewhat tortuous, I have prepared a breakdown):

PROMPT $E[s$E[H$E[30;41m$E[K$E[4CAlt-Enter toggles full screen and window$E[15CType "EXIT" to quit $E[37;40m$E[u$P$G

Which would display:

   Alt-Enter toggles full screen and window Type "EXIT" to quit   

  • The same effect could be achieved using a series of PROMPT statements incorporating %prompt%:
    PROMPT $E[s$E[H$E[30;41m$E[K$E[4C
    PROMPT %prompt%Alt-Enter toggles full screen and window$E[15C
    PROMPT %prompt%Type "EXIT" to quit$E[37;40m$E[u$P$G

  • If Ansi.sys is loaded, most keys can be "remapped". To assign the text "XCOPY c:\data\*.* a: /s/e/m" to Shift-F1:
    PROMPT $E[0;84;"XCOPY c:\data\*.* a: /s/e/m"p$P$G
    Note the terminating "$P$G" so that the standard prompt is displayed. If this was omitted the key would be reassigned but the prompt would simply be a flashing cursor.

File Details:


This page last revised:
December 9, 1999.