Jump to content



Photo

Kill Process


  • Please log in to reply
4 replies to this topic

#1 Vinh

Vinh

    Seeker

  • Active Members
  • 26 posts

Posted 11 March 2011 - 12:30 AM

Sr, my english's very bad :)

I have 2 process:
+ Test.exe path in C:\Test.exe
+ Test.exe path in D:\Test.exe
Their name is both Test.exe
I want to close process "Test.exe" (path in C:\Test.exe) but if I use ProcessClose("Test.exe"), It will close process "Test.exe" (path in D:\Test.exe) and i don't want it close that process :P .
Please help me to close that process I want to close. :)
Thanks all!







#2 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 8,953 posts

Posted 11 March 2011 - 12:39 AM

Are you starting these processes yourself? if so close them via their PID.

#3 Donald8282

Donald8282

    Wayfarer

  • Active Members
  • Pip
  • 93 posts

Posted 11 March 2011 - 08:28 AM

Sr, my english's very bad :)

I have 2 process:
+ Test.exe path in C:\Test.exe
+ Test.exe path in D:\Test.exe
Their name is both Test.exe
I want to close process "Test.exe" (path in C:\Test.exe) but if I use ProcessClose("Test.exe"), It will close process "Test.exe" (path in D:\Test.exe) and i don't want it close that process :P .
Please help me to close that process I want to close. :)
Thanks all!



You could always just change one of the file names.

#4 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,503 posts

Posted 11 March 2011 - 09:53 AM

Try this:
Plain Text         
$PROC_LIST = ProcessList("test.exe") If IsArray($PROC_LIST) Then     For $INDEX = 1 To $PROC_LIST[0][0]         If ProcessGetPath($PROC_LIST[$INDEX][1]) = "C:\Test.exe" Then ProcessClose($PROC_LIST[$INDEX][1])     Next EndIf Func ProcessGetPath($PID)     Local $PATH = ""     $OBJ = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy, (Debug)}!\\.\root\cimv2")     If IsObj($OBJ) Then         $PROC = $OBJ.ExecQuery("select * from win32_Process where ProcessId = " & $PID)         If IsObj($PROC) Then             If $PROC.count <> 0 Then                 For $FIND In $PROC                     $PATH = $FIND.ExecutablePath                     If $PATH <> "" Then ExitLoop                 Next             EndIf         EndIf     EndIf     Return $PATH EndFunc

When the words fail... music speaks

#5 Vinh

Vinh

    Seeker

  • Active Members
  • 26 posts

Posted 11 March 2011 - 12:47 PM

Try this:

Plain Text         
$PROC_LIST = ProcessList("test.exe") If IsArray($PROC_LIST) Then     For $INDEX = 1 To $PROC_LIST[0][0]         If ProcessGetPath($PROC_LIST[$INDEX][1]) = "C:\Test.exe" Then ProcessClose($PROC_LIST[$INDEX][1])     Next EndIf Func ProcessGetPath($PID)     Local $PATH = ""     $OBJ = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy, (Debug)}!\\.\root\cimv2")     If IsObj($OBJ) Then         $PROC = $OBJ.ExecQuery("select * from win32_Process where ProcessId = " & $PID)         If IsObj($PROC) Then             If $PROC.count <> 0 Then                 For $FIND In $PROC                     $PATH = $FIND.ExecutablePath                     If $PATH <> "" Then ExitLoop                 Next             EndIf         EndIf     EndIf     Return $PATH EndFunc

Oh, sr, it working :)
Thank you very much :)

Edited by Vinh, 11 March 2011 - 12:49 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users