Enterprise Software

Timestamp events in Windows 2000 Pro batch files with Now.exe

The Windows 2000 Resource Kit contains the Now.exe command, which allows you to keep track of how long a particular command takes or when specific processes start and stop in the batch file. Learn how you can use Now.exe to timestamp batch events.

When you use batch files or scripts to automate processes, you might also like to keep track of how long a particular command takes or when specific processes start and stop in the batch file.

The Windows 2000 Resource Kit contains a tool that you will find useful for tracking time in this way. The Now.exe command displays the current date and time on the standard output device (by default, the screen). Now.exe is similar to the ECHO command in that it outputs text. However, the text that Now.exe generates contains the current date and time.

In addition to the timestamp, you can have Now.exe add your own message as needed to the output. The syntax for Now.exe is:

Now.exe [message text]

The following is an example and the results of the command:

Example: Now.exe Beginning to copy files...
Result: Wed Aug 24 10:52:24 2005 Beginning to copy files...

The processes handled within many batch files are performed too quickly to be monitored on the display as the batch file runs. In these situations, you can redirect the output of the batch file to a text file for later review. If you call Now.exe in the batch file, the program will redirect the timestamp to the text file.

To redirect output from a batch file to a text file, use the > redirection character, as in the following example:

MyCommands.cmd > MyCommands.txt

Want more Win2K tips and tricks? Automatically sign up for our free Windows 2000 Professional newsletter, delivered each Tuesday!

Editor's Picks

Free Newsletters, In your Inbox