Windows Task Manager has the ability to show the current CPU time of any given running process on windows, is there any way (not necessarily through Task Manager) to get the current wall time of a process?

An example, let's say I have a script that reliably runs for about 45 minutes. Without adding a progress bar to the script, is there any way to figure out for how long it has been running?

The math behind this seems pretty straight forward;

WallTime = CurrentWallTime - WallTimeProcessStarted.

Likewise, since the math is so simple, is there anyway to get the time that a process was started at?

  • 1
    Try Microsoft SysInternal's Process Explorer. It gives you process start time, the time spent in user mode and kernel mode. – Ganesh R. Oct 19 '12 at 16:51
  • "Wall time"? Is that English? You may want to edit the Q. title, or at least lead off with a definition of that phrase. – kreemoweet Oct 19 '12 at 20:44
  • Both "wall clock time" and (less popular) "wall time" are common idioms in the US to mean time as experienced by human observers watching a clock on the wall. – Nicole Hamilton Oct 19 '12 at 21:44

Sure. Total elapsed time is available via the performance section of the registry and via the Toolhelp API. And of course, if you have the elapsed time and the current time, you can compute the start time.

There are two ways to retrieve the information via Win32, but neither one is particularly simple. The way that's been supported since the earliest releases of WinNT is to use RegQueryValueEx to parse first the list of available counters in HKEY_PERFORMANCE_DATA, then retrieve the ones you want on the process instances of interest. A newer way is to use CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS ), which got introduced with WinXP.

There are probably lots of apps that can do this, so you're inviting a list I'm sure others can add to. Here's how I did it in my C shell. ps -s lists all the system processes. The uptime sample utility calculates how long the system has been up from the elapsed time reported by ps -s for the Idle process.

Hamilton C shell ps utility reporting elapsed times for system processes

(The active time for Idle is simply the odd value reported by Win7.)


If you're willing/able to use Python, there's something called psutil which would probably work. Alternatively, you can download its source code and see what Windows API calls it's using to provide the information.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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