Sign in to follow this  
Followers 0
Haseeb

getting process id from the location of exe and kill it.

7 posts in this topic

#1 ·  Posted (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 by GsmExpert

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Pain

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

$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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thats a good one from me... lols

so... is there more ways to do the same ?


Always Keep Your Sig Small... Like me :D

Share this post


Link to post
Share on other sites

Thats a good one from me... lols

so... 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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0