Windows System Uptime and System Information

UNIX systems typically ship with the ‘uptime’ utility to display the operating systems running time, Windows doesn’t include this command however an uptime.exe is available in the Windows Resource Kit and can be downloaded from http://support.microsoft.com/kb/232243.

Having said that current versions of Windows (including XP) ship with the ‘systeminfo’ command line tool that displays the operating system boot time in addition to:

  • Hostname, OS, PC Manufacturer, Model and Speed
  • OS Installation time
  • Memory, Time zone, system folders, BIOS version and locale configuration
  • Domain, Logon Server, Network Card details
  • Installed hot fixes

To display just the OS startup time:

  1. systeminfo |find "System Boot Time:"
  2. System Boot Time:          14/08/2010, 17:32:40

To display it without the ‘System Boot Time’ text you can use the ‘for’ command:

  1. for /f "tokens=4,5" %a in (‘systeminfo ^|find "System Boot Time:"’) do echo %a %b
  2. 14/08/2010, 17:32:40

Or to set an environment variable to the current boot time:

  1. @for /f "tokens=4,5" %a in (‘systeminfo ^|find "System Boot Time:"’) do set boottime=%a %b
  2. echo %boottime%
  3. 14/08/2010, 17:32:40

Note: If you intend to use the above inside a batch file you’ll need to double on the % characters (i.e. %a becomes %%a) – this is a requirement of the for command when used within batch files.

This entry was posted in Scripting & Automation and tagged , , . Bookmark the permalink.

One Response to Windows System Uptime and System Information

Leave a Reply

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