I would like to change the prompt to $p$g$_$f permanently, but it resets itself every time I reopen the command window.

How can I get it to stay the same forever?


6 Answers 6


Create a new environment variable called PROMPT. Set the variable value to the desired prompt.

enter image description here

enter image description here

  • 2
    +1 For being the only answer to mention the important thing in the first sentence. Once one knows that the prompt issued by command interpreters is controlled by an environment variable, the rest devolves into a simple exercise in applying the generic SuperUser answer about environment variables.
    – JdeBP
    Aug 20, 2011 at 2:46
  • Actually, this is not the only answer to mention the creation of the PROMPT variable -- my answer also mentions this in step 4, which reads: 4. Create a variable called "PROMPT" and insert your desired prompt text (...) Aug 20, 2011 at 4:15
  • 2
    Technically my answer mentions the Prompt variable as well since it provides the command to set it. :)
    – EBGreen
    Aug 20, 2011 at 11:22
  • 5
    EBGreen and Randolf Richardson, what about "in the first sentence" is escaping the two of you?
    – JdeBP
    Aug 23, 2011 at 23:08

At the command prompt type:

setx Prompt $p$g$_$f

Then reopen the command prompt.

For anyone that doesn't know how to get help for DOS/CMD commands, type:

setx /?

To get:

SetX has three ways of working:

Syntax 1:
    SETX [/S system [/U [domain\]user [/P [password]]]] var value [/M]

Syntax 2:
    SETX [/S system [/U [domain\]user [/P [password]]]] var /K regpath [/M]

Syntax 3:
    SETX [/S system [/U [domain\]user [/P [password]]]]
         /F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]

    Creates or modifies environment variables in the user or system
    environment. Can set variables based on arguments, regkeys or
    file input.

Parameter List:
    /S     system          Specifies the remote system to connect to.

    /U     [domain\]user   Specifies the user context under which
                           the command should execute.

    /P     [password]      Specifies the password for the given
                           user context. Prompts for input if omitted.

    var                    Specifies the environment variable to set.

    value                  Specifies a value to be assigned to the
                           environment variable.

    /K     regpath         Specifies that the variable is set based
                           on information from a registry key.
                           Path should be specified in the format of
                           hive\key\...\value. For example,

    /F     file            Specifies the filename of the text file
                           to use.

    /A     x,y             Specifies absolute file coordinates
                           (line X, item Y) as parameters to search
                           within the file.

    /R     x,y string      Specifies relative file coordinates with
                           respect to "string" as the search parameters.

    /M                     Specifies that the variable should be set in
                           the system wide (HKEY_LOCAL_MACHINE)
                           environment. The default is to set the
                           variable under the HKEY_CURRENT_USER

    /X                     Displays file contents with x,y coordinates.

    /D     delimiters      Specifies additional delimiters such as ","
                           or "\". The built-in delimiters are space,
                           tab, carriage return, and linefeed. Any
                           ASCII character can be used as an additional
                           delimiter. The maximum number of delimiters,
                           including the built-in delimiters, is 15.

    /?                     Displays this help message.

NOTE: 1) SETX writes variables to the master environment in the registry.

      2) On a local system, variables created or modified by this tool
         will be available in future command windows but not in the
         current CMD.exe command window.

      3) On a remote system, variables created or modified by this tool
         will be available at the next logon session.

      4) The valid Registry Key data types are REG_DWORD, REG_EXPAND_SZ,
         REG_SZ, REG_MULTI_SZ.

      5) Supported hives:  HKEY_LOCAL_MACHINE (HKLM),

      6) Delimiters are case sensitive.

      7) REG_DWORD values are extracted from the registry in decimal

    SETX /S system /U user /P password  MACHINE COMPAQ
    SETX /S system /U user /P password MYPATH ^%PATH^%
    SETX TZONE /K HKEY_LOCAL_MACHINE\System\CurrentControlSet\
    SETX BUILD /K "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
         NT\CurrentVersion\CurrentBuildNumber" /M
    SETX /S system /U user /P password TZONE /K HKEY_LOCAL_MACHINE\
    SETX /S system /U user /P password  BUILD /K
         "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\
         CurrentVersion\CurrentBuildNumber" /M
    SETX /F ipconfig.out /X
    SETX IPADDR /F ipconfig.out /A 5,11
    SETX OCTET1 /F ipconfig.out /A 5,3 /D "#$*."
    SETX IPGATEWAY /F ipconfig.out /R 0,7 Gateway
    SETX /S system /U user /P password  /F c:\ipconfig.out /X
  • 1
    I tried this, too, and it worked perfectly. I had to mark the other guy's as the answer, though, even though yours was more straight and to the point. His was first, so I had to do what's right. I upvoted you, though. Aug 19, 2011 at 13:59
  • 31
    I don't really care who gets marked as the answer. I will point out for future reference though (leave it as it is fo this one) that the key decision for marking an answer is not who answered first it is which answer is best. While it is true that marking the answer is good in that it gives rep, the real reason to mark the answer is to help people that find this question later to more quickly find the best solution. Since there is nothing wrong with the other solution in this particular case it doesn't matter.
    – EBGreen
    Aug 19, 2011 at 14:14
  • 1
    I particularly like this answer (+1) because it shows that there's more than one way to do the same thing (something that's particularly emphasized with Perl [programming]). Aug 19, 2011 at 14:56
  • 3
    I agree that it's not about the first answer. Both of you answered my base question of how to permanently change the prompt. When two people achieve the same thing, the fall-back is to use the first answer. Yours was short and to the point, addressing the bare-bones issue, while his was a more complicated, UI-jumping approach that exposed more options regarding environment variables. I weighed the options carefully before choosing the answer. Aug 19, 2011 at 15:28
  • 2
    It would be great to expand your answer. It is currently lacking context. Please look at our short How to Answer guide to see how you can make your answer better. So, what does setx exactly do and why did it keep resetting itself? Aug 21, 2011 at 0:28

To change the appearance of your DOS Prompt (or "Command Prompt"), right-click on "Computer" (usually on your Windows Desktop or in the Windows Start Menu), then follow these steps:

  1. Click the "Advanced system settings" label
  2. Click the "Environment Variables..." button
  3. Click the "New..." button (a "User variable" only effects you, and "System variables" effect all users)
  4. Create a variable called "PROMPT" and insert your desired prompt text (as I've included for you in the final picture below)
  5. Click the "OK" button to close the "Environment Variables" window
  6. Click the "OK" button to close the "System Properties" window

This change will also survive reboots.

enter image description here

enter image description here

enter image description here

  • 2
    I love how you highlighted where to click in each image. How did you achieve this?
    – Konerak
    Aug 21, 2011 at 14:39
  • 4
    @Konerak: Thanks! I opened each window, pressed Alt-PrintScreen (to copy on the current active window to the Clip Board), then pasted it into Adobe Photoshop. After that, I created a layer on top of (or in front of) the image, filled it with 100% black, changed the layer's opacity to 25% (which allows the image to fade through at a 75% level), then I used the Rectangular Marquee Tool with a "3px feather" to select the area to highlight and pressed the Delete key (to delete from this black layer). After that, I saved the image as a .PNG file in my C:/Temp/ directory and uploaded it here. Aug 21, 2011 at 17:01
  • 1
    I'm a complete photoshop noob, but I see what you're talking about! I'm so gonna try this next time I'm presenting our application to our users - much nicer than the MS Paint red lines all over the screen. Thanks!
    – Konerak
    Aug 22, 2011 at 4:28
  • Snagit costs less thatn Photoshop and gives you a lot of options for working with screen catures as well. It is my favorite for doing screen caps.
    – EBGreen
    Aug 24, 2011 at 14:12
  • Upvoted for explaining how to get to Environment Variables in Windows 7, and for explaining how to highlight an image. Useful geek stuff, here!
    – CigarDoug
    Apr 4, 2013 at 11:24

Edit the menu command or link which starts the command prompt, change its target eg.

%SystemRoot%\system32\cmd.exe /K "prompt $p$g$_$f"

And if wanting an extra space before the cursor:

%SystemRoot%\system32\cmd.exe /K "prompt $p$g$_$f "

Windows comes with Windows PowerShell which allows pipelining among other former Linux-only features.

You can start it by clicking the Start button and entering PowerShell, which gives you three options. Click PowerShell. Right click on the window title bar and select Properties. In the opening window you configure view and behavior settings.

Otherwise instead of opening PowerShell in the first place select and click PowerShell modules.

See the Microsoft documentation for what you can do:

PS: I wouldn't recommend the classic shell if you develop console applications.

  • 1
    Pipes exist in CMD.EXE as well, and work pretty much the same as they classically do on unix. They've been part of the CMD syntax from the earliest public beta releases of NT, and were also part of the command syntax of COMMAND.COM on DOS.
    – RBerteig
    Aug 19, 2011 at 18:44
  • 1
    The huge difference between command shell pipes, *nix shell pipes, and powershell pipes is that the powershell pipes passes objects not strings. This is a game changer imo.
    – EBGreen
    Aug 19, 2011 at 19:32
  • What does the PowerShell have to do with the question?
    – Synetech
    Aug 22, 2011 at 1:33
  • 1
    @Syntech inc. - Nothing directly. Indirectly however it is an alternative to using cmd.exe that would meet the intent of the question by providing a customizeable prompt that could be set via a profile setting.
    – EBGreen
    Aug 24, 2011 at 14:14

Definitive method:

setx prompt ""

For all users:

setx prompt "" /M

Example of prompt customizable, with style:

setx PROMPT "$_$e[0;1;44mN$e[1;30;47mI$e[0;1;44mC$E[35;40m $d$s$t$h$h$h$h$h$h$_$E[1;33;40m$p$_$E[0;0m~$g$s"

You must log in to answer this question.

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