Jump to content

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


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...