Is there any simple way to show how long a specific PID instance has been active?
I know that Process Explorer will show this, sort of.
If you run it, right click on a process and choose
Properties it will show you the start time of the process (and you can click on the
Threads tab there to see individual thread start times).
Alternatively in Process Explorer you can click
Select Columns, choose the
Process Performance tab, and choose
Start Time and then it will show that column in the main window for all PIDs.
You might need to do your own math on the individual threads within that process (again the threads tab) and the current date/time to get a true "how long" answer.
In CMD you can use standard Windows Management Instrumentation Command-line (WMIC) utility to get the process start time:
wmic process where Name="<process name>" get CreationDate
wmic process where ProcessID="<PID>" get CreationDate
You'll get a datetime like this:
If you want a more readable representation you'd need to prep it with a script. Here I have written a little batch script for the purpose:
@ECHO OFF SETLOCAL IF [%1]== ( ECHO Prints process creation date in ISO format. ECHO: ECHO USAGE: %~n0 ^<PID or Process name^> EXIT /B 1 ) IF [%~x1]==[.exe] (SET type=Name) ELSE (SET type=ProcessID) FOR /F "tokens=1,2 delims==" %%a IN ('wmic process where %type%^="%~1" get CreationDate /value') DO ( IF [%%a]==[CreationDate] SET proc_cd=%%b ) IF DEFINED proc_cd ( ECHO %proc_cd:~0,4%-%proc_cd:~4,2%-%proc_cd:~6,2%T%proc_cd:~8,2%:%proc_cd:~10,2%:%proc_cd:~12,2% )
Feed it with a PID or a process name ending with .exe and it will output when the process was started. Caveat: If there are many processes with the same name it would output the time only for the last one started.