ConsoleWrite('--- ProcessStartDate: ' & ProcessStartDate('SciTE.exe') & @CRLF) ; --- ProcessStartDate: 2024/10/28 09:45:50
Func ProcessStartDate($sProcessOrPID, $iRet_tSYSTEMTIME = 0, $iLocalTime = 0)
Local $aFT, $tFT, $tST, $iID = ProcessExists($sProcessOrPID)
If $iID Then ; https://www.autoitscript.com/forum/index.php?showtopic=139260&view=findpost&p=1538034
$aFT = _WinAPI_GetProcessTimes($iID)
If @error Or UBound($aFT) <> 3 Then Return SetError(@error, _WinAPI_GetLastError(), "GetProcessTimes FAILED")
$tST = _Date_Time_FileTimeToSystemTime($iLocalTime ? _Date_Time_FileTimeToLocalFileTime($aFT[0]) : $aFT[0])
If $iRet_tSYSTEMTIME Then Return $tST
Return _Date_Time_SystemTimeToDateTimeStr($tST, 1)
EndIf
Return SetError(11, 0, "Process does not exist")
EndFunc ;==>ProcessStartDate
I have a bunch of RDP running and wanted to identify which is which and thought of the Process date and PID, to know that the given process was from X connection because when it disconnects the popup window does not have any info. in regards to what disconnected ... , am working on it. And thought that the function was a good snippet to share.