promptPROMPT Command Guide - Customize Command Prompt in Windows
Learn how to use the PROMPT command to change the Command Prompt display in Windows CMD. Includes syntax, character codes, examples, and customization tips.
The PROMPT command is a Windows Command Prompt utility that changes the appearance of the command prompt—the text displayed before the cursor where you type commands. Use PROMPT alone to reset to default, or PROMPT followed by text and special character codes (e.g., $P$G for drive and path) to customize the display. Power users and scripters use PROMPT to show current directory, time, date, or custom text for better context while working in CMD.
Whether you're working in multiple directories and need to see the current path at a glance, or you want to distinguish between different CMD windows (e.g., "Production" vs. "Test"), PROMPT provides quick customization without editing registry or system files. The change applies only to the current session, making it safe to experiment.
This comprehensive guide covers PROMPT syntax, all character codes, practical examples for common customizations, troubleshooting tips, and frequently asked questions. By the end, you'll confidently tailor your Command Prompt display for improved productivity.
What Is the PROMPT Command?
The PROMPT command has been part of Windows and MS-DOS for decades, making it one of the most stable CMD utilities. It controls the command prompt string—the text that appears at the start of each line in Command Prompt, such as C:\Users\Public> or a custom format you define.
PROMPT runs in Command Prompt (CMD) only; it does not work in PowerShell (which uses $env:PS1 or the prompt function). The change is session-specific: closing the window or starting a new CMD resets to the default. No administrator privileges are required.
PROMPT Command Syntax
PROMPT [text]
Character Codes (use in text)
| Code | Description |
|---|---|
$A | & (ampersand) |
$B | | (pipe) |
$C | ( (left parenthesis) |
$D | Current date |
$E | Escape character (ASCII 27) |
$F | ) (right parenthesis) |
$G | > (greater-than) |
$H | Backspace (erases previous character) |
$L | < (less-than) |
$N | Current drive |
$P | Current drive and path |
$Q | = (equals) |
$S | Space |
$T | Current time |
$V | Windows version |
$_ | Carriage return and line feed |
$$ | $ (dollar sign) |
If you omit text, PROMPT resets to the default (typically $P$G).
Practical PROMPT Command Examples
Reset to Default Prompt
To restore the standard prompt (drive and path followed by >):
PROMPT
Explanation: Running PROMPT without arguments resets to the default. Use when you've customized and want to return to normal.
Show Drive and Path (Default)
The most common prompt format:
PROMPT $P$G
Output: C:\Users\Public>
Explanation: $P shows current drive and path; $G shows >. This is usually the default. Use explicitly if you've changed the prompt and want this format back.
Show Only Drive Letter
To display just the drive and >:
PROMPT $N$G
Output: C>
Explanation: $N shows only the drive letter. Useful for minimal prompts when you know the path or work mainly on one drive.
Show Date and Time
To include current date and time in the prompt:
PROMPT [$D] [$T] $P$G
Output: [Wed 03/18/2026] [14:30:45.12] C:\Users\Public>
Explanation: $D and $T insert date and time. Helpful for logging or when you need temporal context during long sessions.
Show Windows Version
To display the Windows version in the prompt:
PROMPT $V$S$P$G
Output: Microsoft Windows [Version 10.0.19045.3930] C:\Users\Public>
Explanation: $V shows version; $S adds a space. Useful when working on multiple systems and need to confirm which Windows version you're on.
Custom Text Label
To add a custom label (e.g., for different environments):
PROMPT [PRODUCTION] $P$G
Output: [PRODUCTION] C:\Users\Public>
Explanation: Plain text is displayed as-is. Use to distinguish CMD windows when you have several open (e.g., Production, Test, Dev).
Minimal Prompt
For maximum space to type commands:
PROMPT $$
Output: $
Explanation: $$ displays a single $. Minimal and clean. Some users prefer this for less visual clutter.
Multi-Line Prompt
To put the path on one line and input on the next:
PROMPT $P$_$G
Output:
C:\Users\Public
>
Explanation: $_ inserts a newline. Puts the path above the > so the prompt doesn't wrap on long paths.
Prompt with User Name (via SET)
To include username (requires SET for variable):
PROMPT [$USERNAME] $P$G
Explanation: If USERNAME is set in the environment, it displays. Use SET USERNAME=YourName first, or rely on system USERNAME variable if present.
Batch Script: Set Prompt at Start, Reset at End
In a batch file:
@echo off
PROMPT [Script Running] $P$G
REM ... do work ...
PROMPT
Explanation: Customize prompt at script start for visibility, reset at end so the user's session returns to normal.
Common Use Cases for the PROMPT Command
-
Path visibility – Use
$P$Gto always see the current directory. Essential when navigating deep directory trees or multiple drives. -
Environment labeling – Use
PROMPT [PROD] $P$GorPROMPT [TEST] $P$Gwhen you have multiple CMD windows for different environments. Reduces risk of running commands in the wrong context. -
Timestamp in prompt – Use
$Dand$Twhen you need to correlate command output with real time (e.g., during debugging or logging). -
Minimal distraction – Use
PROMPT $$orPROMPT $N$Gfor a clean prompt when you prefer maximum space for long commands. -
Training and demos – Use a custom prompt like
PROMPT [DEMO] $P$Gduring training so the audience knows they're watching a demo environment. -
Batch script context – Set a distinctive prompt at the start of a batch script so you can tell when the script is running vs. idle CMD.
-
Version awareness – Use
$Vwhen supporting multiple Windows versions and you need to quickly confirm which one you're connected to. -
Multi-line for long paths – Use
$P$_$Gwhen working with very long paths so the prompt doesn't wrap awkwardly. -
Logging and documentation – When capturing session output, a prompt with date/time helps timestamp the log.
-
Remote session identification – When connected via RDP or SSH, a custom prompt can indicate which server or session you're in.
-
Accessibility – Some users prefer larger or simpler prompts. PROMPT allows customization without changing system-wide settings.
-
Automation scripts – In automated batch jobs, a custom prompt can help identify the script's CMD window in Task Manager or when debugging.
Tips and Best Practices
-
Keep it readable – Avoid overly long prompts that wrap or obscure your commands.
$P$Gor$N$Gare usually sufficient. -
Use labels for multiple windows – When you have several CMD windows open, add a short label:
PROMPT [1] $P$G,PROMPT [2] $P$G, etc. -
Reset in batch scripts – If your script changes PROMPT, restore it at the end with
PROMPT(no args) so the user's session isn't permanently changed. -
Date/time can slow prompt –
$Dand$Tare evaluated each time the prompt is displayed. On very slow systems, this can add a tiny delay. Usually negligible. -
Document custom prompts – If you use a custom prompt in scripts or profiles, document the format so others understand what they're seeing.
-
Test before committing – Try different PROMPT formats in a test CMD window before adding to login scripts or batch files.
-
Combine with TITLE – Use PROMPT for the prompt text and TITLE for the window title. Together they improve context:
TITLE Production ServerandPROMPT [PROD] $P$G. -
Avoid special characters – Some characters may need escaping or can cause issues. Stick to PROMPT codes and simple text.
-
Session-only – Remember PROMPT changes don't persist. For permanent customization, add PROMPT to AutoRun in registry or use a profile script.
-
PowerShell is different – PROMPT doesn't work in PowerShell. Use
$env:PS1or define apromptfunction there.
Troubleshooting Common Issues
Prompt Change Doesn't Persist
Problem: After closing CMD, the prompt resets to default.
Cause: PROMPT changes are session-specific. This is by design.
Solution: For persistent customization, add PROMPT to the AutoRun registry key: HKCU\Software\Microsoft\Command Processor\AutoRun with value PROMPT $P$G (or your format). Or create a batch file that runs at login and sets PROMPT.
Prevention: Document that PROMPT is session-only. Use AutoRun or login scripts for persistence.
PROMPT Not Recognized in PowerShell
Problem: Typing PROMPT in PowerShell doesn't change the prompt or returns an error.
Cause: PROMPT is a CMD command. PowerShell uses a different mechanism.
Solution: In PowerShell, use $env:PS1 = "MyPrompt> " or define a function prompt { "MyPrompt> " }. See PowerShell documentation for prompt customization.
Prevention: Use CMD for PROMPT. Use PowerShell's prompt function for PowerShell.
Prompt Too Long or Wraps
Problem: The prompt is so long it wraps to the next line or obscures the command.
Cause: Long path with $P, or too much text/codes in the prompt.
Solution: Use $N$G for just drive, or $P$_$G to put path on its own line. Shorten custom text.
Prevention: Prefer shorter formats. Use $N when full path isn't needed.
Special Characters Break the Prompt
Problem: Including certain characters in PROMPT causes unexpected behavior.
Cause: Some characters have special meaning in CMD (e.g., &, |, >).
Solution: Use PROMPT codes: $G for >, $L for <, $B for |, $A for &. For literal $, use $$.
Prevention: Use PROMPT codes instead of raw special characters. Test in a new CMD window.
AutoRun PROMPT Overrides Manual Change
Problem: Every time you open CMD, the prompt resets to a specific format.
Cause: AutoRun in registry or a startup script is setting PROMPT.
Solution: Check HKCU\Software\Microsoft\Command Processor\AutoRun and HKLM\...\AutoRun for values that run PROMPT. Remove or modify if you want a different default.
Prevention: Document AutoRun settings. Avoid setting PROMPT in AutoRun if users prefer to customize manually.
Prompt Shows Wrong Path
Problem: The prompt shows a path that doesn't match the actual current directory.
Cause: Rare—usually a bug or very unusual scenario. Could be drive mapping or subst confusion.
Solution: Run CD to verify current directory. Run PROMPT $P$G to refresh. Check for SUBST or PUSHD/POPD state.
Prevention: Use standard navigation. Avoid mixing SUBST and complex PUSHD/POPD without understanding state.
Related Commands
TITLE – Window Title
TITLE sets the Command Prompt window title. Use TITLE for the window caption; use PROMPT for the text before the cursor. Together they improve context.
When to use PROMPT: What you see at the start of each command line. When to use TITLE: What you see in the taskbar and window title bar.
CD / CHDIR – Change Directory
CD changes the current directory. The path shown in PROMPT (when using $P) updates when you use CD. PROMPT displays the path; CD changes it.
When to use PROMPT: Customize how the path (or other info) is displayed. When to use CD: Navigate to a different directory.
SET – Environment Variables
SET creates environment variables. You can reference variables in PROMPT if your prompt string includes them (e.g., via a batch wrapper). PROMPT itself doesn't expand variables directly; use a batch file that does SET PROMPTSTR=... and PROMPT %PROMPTSTR%.
When to use PROMPT: Direct prompt customization with codes. When to use SET: Store values (e.g., custom text) for use in PROMPT via batch.
CLS – Clear Screen
CLS clears the screen. Use after changing PROMPT to clear old output and see your new prompt clearly.
When to use PROMPT: Change the prompt. When to use CLS: Clear the display.
COLOR – Console Colors
COLOR changes foreground and background colors. Use with PROMPT for a customized look: PROMPT for text, COLOR for appearance.
When to use PROMPT: What the prompt says. When to use COLOR: How the console looks.
Frequently Asked Questions
What does the PROMPT command do?
PROMPT changes the command prompt—the text displayed before the cursor in Command Prompt. Use it to show drive, path, date, time, version, or custom text. Run PROMPT without arguments to reset to default.
How do I reset the prompt to default?
Run PROMPT with no arguments. This restores the default prompt, typically $P$G (drive and path followed by >).
What does $P$G mean in PROMPT?
$P displays the current drive and path (e.g., C:\Users\Public). $G displays >. So PROMPT $P$G shows something like C:\Users\Public>.
Can I make PROMPT changes permanent?
PROMPT changes are session-only. For persistence, add a PROMPT command to the AutoRun registry key (HKCU\Software\Microsoft\Command Processor\AutoRun) or to a batch file that runs at login.
Does PROMPT work in PowerShell?
No. PROMPT is a CMD command. In PowerShell, use $env:PS1 or define a prompt function to customize the prompt.
How do I show the date and time in the prompt?
Use PROMPT [$D] [$T] $P$G. $D shows the date; $T shows the time. Adjust format as needed.
What are all the PROMPT character codes?
Common codes: $P (path), $G (>), $N (drive), $D (date), $T (time), $V (version), $_ (newline), $$ ($). See the full table in the Syntax section.
How do I add custom text to the prompt?
Include it in the PROMPT string: PROMPT [My Label] $P$G. Plain text is displayed as-is. Use PROMPT codes for dynamic content.
Why does my prompt reset when I open a new CMD window?
Each CMD session starts with the default prompt. PROMPT changes apply only to the current session. Use AutoRun or a startup script for persistence.
Can I use PROMPT in a batch file?
Yes. Add PROMPT your_format at the start of the batch file. To restore the user's prompt when the script ends, add PROMPT (no args) at the end.
How do I show only the drive letter in the prompt?
Use PROMPT $N$G. $N shows the current drive; $G shows >. Result: C>.
What is the default prompt in Windows?
The default is typically $P$G, which displays the current drive and path followed by >, e.g., C:\Users\Public>.
Quick Reference Card
| Command | Purpose | Example Use Case |
|---|---|---|
PROMPT | Reset to default | Restore standard prompt |
PROMPT $P$G | Drive and path | Default, most common |
PROMPT $N$G | Drive only | Minimal, just C> |
PROMPT [$D] [$T] $P$G | Date, time, path | Timestamp in prompt |
PROMPT [LABEL] $P$G | Custom label | Distinguish windows |
PROMPT $$ | Single $ | Ultra-minimal |
PROMPT $P$_$G | Path on own line | Long path display |
PROMPT $V$S$P$G | Version, path | Show Windows version |
Try the PROMPT Command in Our Simulator
Practice the PROMPT command in our Windows Command Simulator. Try PROMPT $P$G, PROMPT [TEST] $P$G, and other formats in your browser. Perfect for learning prompt customization without affecting your system.
Visit the Commands Reference for a full list of supported Windows CMD commands, including system information and customization utilities.
Summary
The PROMPT command customizes the Command Prompt display in Windows CMD. Use PROMPT alone to reset to default, or with text and codes like $P$G (path and >), $D (date), $T (time), and $V (version) for custom formats. Changes are session-only unless you add PROMPT to AutoRun or a startup script.
Key use cases include path visibility, environment labeling, timestamps, minimal prompts, and batch script context. PROMPT does not work in PowerShell—use PowerShell's prompt mechanism there. Combine PROMPT with TITLE and COLOR for a fully customized CMD experience.