NAME - Uptime for Windows. Version 0.27.


perl [debug]


Report machine uptime on Windows systems.

This script attempts to report the system uptime in a format similar to the Unix uptime command. It only reports uptime, not users or load statistics.

On NT it uses the event log. The event log service itself writes an entry to it when it starts (ID 6005).

On Win95 it gets the create time of the system.da0 file (the system.dat backup file which is recreated at system start).

If eihter of these methods fail (like on Win98), it uses the system tick counts. Since these can only hold about 49.7 days, it returns a list of possible uptimes, limited to $max_results (5 by default). (Have you ever seen a Windows system up for more than 200 days? ;-) If yes, set $max_results to a higher value).

The script can be used in CGI. It will print the needed headers automatically.

The latest version should always be available at


If given any argument (at the command line or as a CGI argument), it is considered as a 'debug' or 'verbose' option, and additional stuff is printed.


On NT, the uptime will be wrong if you restarted the event log service.

If you have a low limit on your event log file size or logged events, and your system has been up for a long time, the event may not be available anymore. The script will then use tick counts.

On Win95, the uptime will be wrong if the create time of your system.da0 file is not the same as when your system booted. I don't see what could cause this unless you overwrite the file, but there may be special cases. Let me know if you find any.

On Win98, there seems to be no way other than tick counts. Let me know if you find something better.






M. Ivkovic. email: perl -e "printf '%s@%s', 'mi.perl', ''".

Others welcome to extend it to more operating systems which don't have an uptime command.


Copyright M. Ivkovic, 1999. Same license as Perl itself.


Attempt to report machine uptime on various Windows systems.