Ayke Posted April 17, 2008 Posted April 17, 2008 Hello, is there a function which tells me how long a process is running ? CPU-TIME and IDLE Time would be fine. Actually i use pslist from sysinternals to get the information, i write it down into a file and then i again read it with autoit. It Works but it could be better :| Regards www.m3rry.de | nach müde kommt blöd
monoceres Posted April 17, 2008 Posted April 17, 2008 Have a look at this.I'm at a shared computer so I cannot work out an example though... Broken link? PM me and I'll send you the file!
covaks Posted April 17, 2008 Posted April 17, 2008 You could try something like this as well. You'd just have to parse the datetime string. $sComputer = "." $oWmi = ObjGet("winmgmts:\\" & $sComputer & "\root\cimv2") $oClass = $oWmi.ExecQuery("Select * from Win32_Process") For $obj in $oClass msgbox(1,"",$obj.Name & " Created: " & $obj.CreationDate) Next
FreeFry Posted April 17, 2008 Posted April 17, 2008 You could try something like this as well. You'd just have to parse the datetime string. $sComputer = "." $oWmi = ObjGet("winmgmts:\\" & $sComputer & "\root\cimv2") $oClass = $oWmi.ExecQuery("Select * from Win32_Process") For $obj in $oClass msgbox(1,"",$obj.Name & " Created: " & $obj.CreationDate) NextoÝ÷ Ûú®¢×«¢é]mç±µéÝyÖòªç«Ëbè«)yÈÊk¡Ç¬±«¢+ØÀÌØí½]µ¤ô=©Ð ÅÕ½ÐíÝ¥¹µµÑÌèÀäÈìÀäÈì¸ÀäÈíɽ½ÐÀäÈí¥µØÈÅÕ½Ðì¤(ÀÌØí½ ±ÍÌôÀÌØí½]µ¤¹áEÕÉä ÅÕ½ÐíM±Ð¨É½´]¥¸ÌÉ}AɽÍÌ]¡É9µôÌäíÕѽ¥Ð̹áÌäìÅÕ½Ðì¤()½ÈÀÌØí½¨¥¸ÀÌØí½ ±ÍÌ(%µÍ½à İÅÕ½ÐìÅÕ½Ðì°ÀÌØí½¨¹9µµÀìÅÕ½Ðì ÉÑèÅÕ½ÐìµÀìÀÌØí½¨¹ ÉÑ¥½¹Ñ¤)9áoÝ÷ ÚÚºÚ"µÍÌÍÛÕÛZHHØÙ] ][ÝÝÚ[YÛ]ÎÌLÉÌLËÌLÜÛÝ ÌLØÚ[]][ÝÊBÌÍÛÐÛÜÈH ÌÍÛÕÛZK^XÔ]YJ ][ÝÔÙ[XÝ ÛHÚ[ÌÔØÙÜÈÚHØÙÜÒYH ÌÎNÉ][ÝÈ [È]]Ò]Q [È ][ÝÉÌÎNÉ][ÝÊBÜ ÌÍÛØ[ ÌÍÛÐÛÜÂ[ÙØÞ K ][ÝÉ][ÝË ÌÍÛØ[YH [È ][ÝÈÜX]Y ][ÝÈ [È ÌÍÛØÜX][Û]JB^ Adiditonal way of query the Win32_Process class can be found here: http://msdn2.microsoft.com/en-us/library/a...372(VS.85).aspx
Ayke Posted April 18, 2008 Author Posted April 18, 2008 I don't had time right now to check any answer, im on it this Weekend, thanks for your reply. Feedback soon www.m3rry.de | nach müde kommt blöd
weaponx Posted April 18, 2008 Posted April 18, 2008 This was completed in another topic a while back:http://www.autoitscript.com/forum/index.ph...ssStartDateTime
Ayke Posted April 18, 2008 Author Posted April 18, 2008 This was completed in another topic a while back:http://www.autoitscript.com/forum/index.ph...ssStartDateTimeoh, ok... ill better use the search funtion next time. Thanks anyways for your Replys www.m3rry.de | nach müde kommt blöd
Ayke Posted April 30, 2008 Author Posted April 30, 2008 I changed the Select to ProcessID and killed the PID not Processname Its better, if you have multiple proccesses running and you want to make sure to pick the right one. Added a CloseProcess after specific duration (was one of my targets). #include <Date.au3> $pname = "Notepad.exe" ; processname $idletime = 24 ; time after $pname gets closed Idle() Func Idle() $pid = ProcessExists ($pname) $ptime = ProcessStartDateTime($pid) $datecalc = _DateDiff( 'h',$ptime,_NowCalc()) ;MsgBox( 4096, $pname, "is running since : " & $datecalc & " hours" ) If $datecalc > $idletime Then ProcessClose($pid) EndIf EndFunc Func ProcessStartDateTime($psdtid) $objwmi = ObjGet("winmgmts:\\localhost\root\CIMV2") $psdtquery = "SELECT * FROM Win32_Process WHERE ProcessID = " & $psdtid $colItems = $objwmi.ExecQuery($psdtquery, "WQL", 0x10 + 0x20) If IsObj($colitems) Then ; For $objitem In $colitems $tdate = $objitem.CreationDate Return StringFormat("%s/%s/%s %s:%s:%s",StringLeft($tdate, 4),StringMid($tdate, 5, 2),StringMid($tdate, 7, 2),StringMid($tdate, 9, 2), StringMid($tdate, 11, 2),StringMid($tdate,13, 2)) Next Else Return SetError(1,1,0) Endif EndFunc Thanks for your work sincerly m3rry www.m3rry.de | nach müde kommt blöd
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now