Simple batch file clock

A very simple batch file clock to run in a command prompt or powershell window.
This was intially written to watch for OS freezes for Wolf68k, when he was streaming. The concept is simple: show an ever changing display which will cease updating during system freezes. I’ll go over the lines one at a time below.


|@echo off
|title JDenslinger's local system Time
|color 0a
|cls
| :CLOCK
| | cls
| | echo %time%
| | ping localhost -n 1 >null
| goto CLOCK

wordpress seems to want to delete all my extra space. I hate it. so, here, in the code section, there is a pipe | preceeding the lines. Remove the pipes if you use this code, otherwise it will not function properly or at all!

@echo off
– Ths provides for the system to not show any of the commands, and to only output the time
title JDenslinger’s local system Time
– two parts here, to form the titlebar display:
— title – the command to initiate the titlebar display
— JDenslinger’s local system time – the words to be displayed.
color 0a
– the background (0) and text (a) colors, black and lime, respectively
cls
– clears the screen, ensuring that the display is only a single line
:CLOCK
– basic function pointer, can be called later in the script
cls
– this clears the previous time allow for the new time to be displayed
echo %time%
– echo (output to the display) the current time (%time% is a system variable)
ping localhost -n 1 >null
– poor man’s timer. On very slow systems, this can more close to a second or longer delay.
goto CLOCK
– This directs the script to go back to our function pointer, creating an infinite loop.

This script can be stopped with ctrl-c or by closing the window.

One thought on “Simple batch file clock”

Leave a Reply

Your email address will not be published. Required fields are marked *