Haseeb Posted May 27, 2008 Share Posted May 27, 2008 (edited) hi, i have two processes running with the same name. how can i get the PID from the location of exe and kill which i want. for example if two procees with the name Program.exe are running then how to kill which is running from d:\installed\ and the second is running from @ProgramDir & "\HHC" please help me in this situation. thanks! Edited May 27, 2008 by GsmExpert Link to comment Share on other sites More sharing options...
Jos07 Posted May 27, 2008 Share Posted May 27, 2008 a example which will end your process which you want $gethandle = \"C:\\1.exe\" FileClose($gethandle) $gethandle = \"2.exe\" FileClose($gethandle) ProcessClose(\"C:\\1.exe\") ProcessClose(\"2.exe\") hope now you have understood what to do... if still could not understand then ask again. Always Keep Your Sig Small... Like me :D Link to comment Share on other sites More sharing options...
Pain Posted May 27, 2008 Share Posted May 27, 2008 (edited) From the helpfile:Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"If multiple processes have the same name, the one with the highest PID is terminated--regardless of how recently the process was spawned. Edited May 27, 2008 by Pain Link to comment Share on other sites More sharing options...
Jos07 Posted May 27, 2008 Share Posted May 27, 2008 yes, but getting file handle is good to kill the process which we want. it is easy from getting PID (Process id) . like this example... ProcessClose(\"notepad.exe\") $PID = ProcessExists(\"notepad.exe\") ; Will return the PID or 0 if the process isn\'t found. If $PID Then ProcessClose($PID) Always Keep Your Sig Small... Like me :D Link to comment Share on other sites More sharing options...
Valuater Posted May 27, 2008 Share Posted May 27, 2008 $PID = Run("notepad.exe") WinWaitActive("") MsgBox(0x0,"PID/Path", _PidGetPath($PID)) Func _PidGetPath($pid = "", $strComputer = 'localhost') If $pid = "" Then $pid = WinGetProcess(WinGetTitle("")) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then Return $objItem.ExecutablePath Next EndIf EndFunc ;==>_PidGetPath 8) Link to comment Share on other sites More sharing options...
Jos07 Posted May 27, 2008 Share Posted May 27, 2008 Thats a good one from me... lols so... is there more ways to do the same ? Always Keep Your Sig Small... Like me :D Link to comment Share on other sites More sharing options...
SadBunny Posted May 27, 2008 Share Posted May 27, 2008 Thats a good one from me... lolsso... is there more ways to do the same ?You should definitely check out the CompInfo.au3 udf file (http://www.autoitscript.com/forum/index.php?showtopic=29404)! This is a ridiculously useful collection of very easy and very powerful info gathering. OS patch level, laptop battery information, very detailed process information, name it and it's got it.Have fun! Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
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