Windows Tip Sheet

Personal Prompts

Customize the CMD prompt with computer and user names.

I've written about customizing your CMD prompts in the past and here's another idea. What about adding the user name and or computer name to the prompt? With not much work you can your CMD session so that is has a prompt like one of these:

[SAPIEN\JEFF] C:\Windows>
[VISTADESK02] C:\Windows>

To try these out, open a command prompt and type:

Prompt [%userdomain%\%username%] $P$G

This should give you a prompt that looks like my first example. Don't worry -- right now this is only temporary. If you close and reopen your command prompt you'll get the "old" prompt back. To get the second prompt example, use this:

Prompt [%computername%] $P$G

Or, what about adding something like this:

Prompt %computername% $V $P$G

You should get something that looks like this:

VISTADESK01 Microsoft Windows [Version 6.0.6000] C:\Users\Jeff>

These are but a few examples. Take a look at help for the prompt command to see other options.

How do you make this permanent every time you open a command prompt? First, copy the prompt command to a text file and save it as a batch file. Next, edit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor. If you don't have a registry key called AutoRun, add it as type REG_SZ and enter the full path and filename to your prompt batch file as its value.

The next time you open a command window, the batch file will run and you'll have a custom and personalized prompt.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular