Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to know how long our computer is on, i.e. not in standby mode, for any given calendar day. Is there a (free) program that extracts this information from the Windows System event log into, say, CSV format, that works on Windows XP?

share|improve this question
    
Similar to superuser.com/questions/28567/… but for standby rather than hibernation –  Kev Sep 5 '12 at 14:45
add comment

1 Answer

up vote 0 down vote accepted

2 choices, the first is easier but doesn't export to CSV.

Option 1

From the Start menu click on Run and type cmd and press enter on your keyboard.

From the Command Prompt window, type

systeminfo | find "Up Time"

Please note, the code above is case sensitive.

Option 2

Also, the following powershell script does it.

<#
.SYNOPSIS
    Collects uptime information and exports to csv-file.
.DESCRIPTION
    Collects information about uptime and last reboot date from one or more computers and exports result to a csv-file located in logged on users "Documents" special folder. If this file already exists (the command has been run earlier the same day) it will append the new information to the same file.
.PARAMETER ComputerName
    Gets information from specified computers. Type the name of one or more computers in a comma-separated list. Default is localhost.
.PARAMETER Credential
    Specifies credentials that has permission to perform WMI-queries on remote machines. Use the object returned by the Get-Credential cmdlet as argument. For local access impersonation level 3 is always used (see Get-WMIObject). Default is current user.
.LINK
    2012 Scripting Games:
    https://2012sg.poshcode.org
.NOTES
    Author : Jesper Strandberg
    Date   : 2012-04-15
#>
function Export-Uptime {
    [CmdletBinding()]
    param (
        [parameter(ValueFromPipeline = $true)]
        [string[]]$ComputerName = $Env:COMPUTERNAME,

        [Management.Automation.PSCredential]
        $Credential
    )

    begin {
        $LocalMachineAliases = $Env:COMPUTERNAME,'localhost','127.0.0.1','::1','.'
        $Result = @()
    }

    process {
        foreach ($Computer in $ComputerName) {
            Write-Verbose "Building parameters for $Computer"
            $WmiParam = @{ Class = "Win32_OperatingSystem";
                           Property = "LastBootUpTime";
                           ComputerName = $Computer }

            if (-not ($LocalMachineAliases -contains $Computer) -and $Credential) {
                Write-Verbose "Adding credentials for $Computer"
                $WmiParam.Add("Credential", $Credential)
            }

            Write-Verbose "Accessing $Computer"
            try { $OS = Get-WmiObject @WmiParam -ErrorAction Stop }
            catch { Write-Warning $_; continue }

            Write-Verbose "Calculating uptime"
            $BootUpTime = $OS.ConvertToDateTime($OS.LastBootUpTime)
            $Uptime = New-TimeSpan -Start $BootUpTime -End "8 am"
            if ($Uptime -lt 0) { $Uptime = New-TimeSpan }

            Write-Verbose "Building custom object"
            $Properties = @{ ComputerName = $Computer;
                             Days = $Uptime.Days;
                             Hours = $Uptime.Hours;
                             Minutes = $Uptime.Minutes;
                             Seconds = $Uptime.Seconds;
                             Date = (Get-Date -Format d -Date $BootUpTime) }
            $Result += New-Object PSCustomObject -Property $Properties
        } # foreach
    } # process

    end {
        Write-Verbose "Exporting results to CSV"
        $CSV = $Result | Select-Object -Property ComputerName,Days,Hours,Minutes,Seconds,Date |
               ConvertTo-Csv -NoTypeInformation -Delimiter ';'

        $OutFile = "$([System.Environment]::GetFolderPath('Personal'))\$(Get-Date -UFormat %Y%m%d)_Uptime.csv"
        try {
            if (-not (Test-Path $OutFile)) {
                Write-Verbose "Creating $OutFile"
                $CSV | Out-File $OutFile -Encoding ASCII -ErrorAction Stop
            } else {
                Write-Verbose "Appending to $OutFile"
                $CSV | Select-Object -Skip 1 | Out-File $OutFile -Encoding ASCII -Append -ErrorAction Stop
            }
        } # try
        catch { Write-Warning $_ }
    } # end
} # function

Source

EDIT

Now, after re-reading your question, I think the answer is to use event Log XP as lots of people say it's customizable (but I've not used it before).

About the software: Event Log Explorer helps you to quickly browse, find and report on problems, security warnings and all other events that are generated within Windows. Thanks to Event Log Explorer, monitoring and analysis of events recorded in Security, System, Application, Directory Service, DNS, and other logs of Microsoft Windows operating systems gets much faster and really effective.

share|improve this answer
    
Option 1 (besides not working on a non-English version of Windows ;) ) only shows total uptime since last restart (e.g. 4 days...), not how much uptime there was on a particular date (e.g. on Tuesday my laptop was on and not in standby mode for 3 hours). –  Kev Sep 5 '12 at 14:03
    
I'm sorry Kev, I totally didn't understand your question. Let me look again for you. –  Dave Rook Sep 5 '12 at 14:05
    
No worries. I've installed PowerShell and am giving Option 2 a try in a minute. The link in your comment though is for Win7, not XP. –  Kev Sep 5 '12 at 14:16
    
Okay, the thing with all of these is, you're tracking shutdown events, but standby needs to be taken into account... –  Kev Sep 5 '12 at 14:26
1  
Well, my last suggestion is to review eventlogxp.com as lots of people say it's customizable but I've not used it before. –  Dave Rook Sep 5 '12 at 14:28
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.