command prompt time

1 Mar

========================================================================
SPONSOR: Fast and Easy Backup Software for Windows Servers ========================================================================
Looking for backup software that is easy to use, fast and affordable?
Try Backup for Workgroups. Supports Exchange Server, Active Directory, MS-SQL, Open Files, 256-bit encryption. Stores backup data to disk-based devices. Built in mirroring. Color coded emails show you backup results.

Download 30-day trial at:
http://info.101com.com/default.aspx?id=35787
========================================================================

I’ve modified my prompts, both in CMD and PowerShell so that they always display the current time and date. The time and date display isn’t a clock, per se. The time is updated every time I press Enter.
It looks like this:

[Wed 01/17/2007 21:11:02.12] C:\>

To modify my prompt in the CMD shell, I simply use the command:

set prompt=[$D $T] $P$G

The $D attribute displays the date, $T the time, $P the current directory and $G the right angle bracket. I enclosed the date and time in square brackets purely for cosmetic purposes.

Since I don’t want to enter this command every time I open a command shell (plus, I have some shell customizations such as my DOSKEY macros), I’ve created a batch file that includes the prompt command.
I then entered the path to the batch file in the AutoRun key under:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor

If you don’t have the key, you can create it. It is type REG_SZ.

Now, all my CMD shells show me the current date and time and all I have to do is look straight ahead and keep working.

Next week, I’ll show you how to handle this with PowerShell.