How to Check Process Uptime for Windows 7/Server 2008 by PID


1 views

When troubleshooting performance issues or monitoring system resources, knowing how long a specific process has been running is often crucial. While newer Windows versions provide more built-in tools, Windows 7 and Server 2008 require some technical approaches.

The most reliable way to get precise uptime information is through WMI queries:

wmic process where "ProcessID=1234" get CreationDate,Name

This returns output in UTC format like 20231010142530.500000+000, which you can calculate against current time.

For more readable output, use this PowerShell script:

$process = Get-Process -Id 1234
$startTime = $process.StartTime
$uptime = (Get-Date) - $startTime
Write-Host "Process $($process.Name) (PID $($process.Id)) has been running for $($uptime.Days) days, $($uptime.Hours) hours"

If PowerShell isn't available, combine these commands:

for /f "tokens=1-2 delims=," %a in ('wmic process where "ProcessID=1234" get CreationDate^,Name /format:csv') do @echo Process %b started at %a
  • Process start times won't persist after system reboots
  • Some system processes may not expose start time information
  • For services, consider using sc queryex [servicename] instead

For regular monitoring, save this as a .bat file:

@echo off
set PID=1234
for /f "tokens=2 delims==" %%A in ('wmic process where "ProcessID=%PID%" get CreationDate /value') do set start=%%A
echo Process start time: %start:~0,8% at %start:~8,6%

When troubleshooting Windows systems, knowing how long a particular process has been running can be crucial for performance analysis or debugging. While newer Windows versions offer more built-in tools, Windows 7 and Server 2008 require some creative solutions.

The simplest method uses Windows Management Instrumentation Command-line (WMIC):

wmic process where "ProcessId=1234" get CreationDate

This returns UTC timestamp in format YYYYMMDDHHmmss.microseconds+offset. You'll need to calculate the duration manually from current time.

For more flexibility, PowerShell provides better options. This script displays running time for a specific PID:

$process = Get-Process -Id 1234 -ErrorAction SilentlyContinue
if ($process) {
    $uptime = (Get-Date) - $process.StartTime
    Write-Host "Process $($process.Name) (PID $($process.Id)) has been running for:"
    Write-Host "$($uptime.Days) days, $($uptime.Hours) hours, $($uptime.Minutes) minutes"
} else {
    Write-Host "Process with PID 1234 not found"
}

For GUI-based analysis, Sysinternals Process Explorer shows process start time in its default view:

  1. Download from Microsoft's site
  2. Run as Administrator
  3. Locate your process in the list
  4. Check the "Start Time" column

For frequent use, create a batch file (procuptime.bat):

@echo off
setlocal
set pid=%1
for /f "tokens=1-2 delims==" %%A in ('wmic process where "ProcessId=%pid%" get CreationDate /value ^| find "="') do (
    set datetime=%%B
)
set year=%datetime:~0,4%
set month=%datetime:~4,2%
set day=%datetime:~6,2%
set hour=%datetime:~8,2%
set minute=%datetime:~10,2%
set second=%datetime:~12,2%

echo Process %pid% started at: %day%-%month%-%year% %hour%:%minute%:%second%

Run with: procuptime.bat 1234

Remember that WMIC returns UTC time. This PowerShell snippet converts to local time:

$process = Get-Process -Id 1234
$utcTime = [DateTime]::ParseExact(
    (wmic process where "ProcessId=1234" get CreationDate | Select-Object -Skip 1).Trim(),
    "yyyyMMddHHmmss.ffffff",
    $null
)
$localTime = $utcTime.ToLocalTime()
Write-Host "Process started at (local time): $localTime"