Vinh Posted March 11, 2011 Share Posted March 11, 2011 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 . Please help me to close that process I want to close. Thanks all! Link to comment Share on other sites More sharing options...
JohnOne Posted March 11, 2011 Share Posted March 11, 2011 Are you starting these processes yourself? if so close them via their PID. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Donald8282 Posted March 11, 2011 Share Posted March 11, 2011 Sr, my english's very bad I have 2 process:+ Test.exe path in C:\Test.exe+ Test.exe path in D:\Test.exeTheir name is both Test.exeI 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 .Please help me to close that process I want to close. Thanks all!You could always just change one of the file names. Link to comment Share on other sites More sharing options...
Andreik Posted March 11, 2011 Share Posted March 11, 2011 Try this: $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. Link to comment Share on other sites More sharing options...
Vinh Posted March 11, 2011 Author Share Posted March 11, 2011 (edited) Try this: $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 March 11, 2011 by Vinh 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