Debug a Windows XP batch file and output the current date and time to a log file

August 21, 2009
The Windows 2003 Resource Kit comes with a batch file command, logtime, that lets you output the current time, date, and a custom text message to a log file. This is great for benchmarking batch files and commands in that you can output when such a command starts and completes.

To run logtime, first download and install the Windows Server 2003 Resource Kit using the instructions mentioned in MalekTips (check the other Windows XP and DOS command tips).

Once the Resource Kit is installed, to view the online help for logtime:

C:\>logtime /?

To write a message to the text file "logtime.log" in the current directory, just issue this command:

C:\>logtime "MESSAGE"

For example, the following command will write the current day, time, and message "Command just completed" to the file logtime.log:

C:\>logtime "Command just completed"

Note that this will display the results of the command to the standard output as well. To hide this:

C:\>@logtime "Command just completed" > nul

Related Posts

Next Article
« Prev Post
Previous Article
Next Post »

4 comments