zFrank Posted August 18, 2008 Posted August 18, 2008 (edited) hi, i am having 4 processes running with same name but from different locations and want to kill 2 of them. how can i do it? because if i will use ProcessClose("Zensis.exe") then it may kill other process which i dont want to kill. all the processes are running from different places... what should i do? i searched the forum and got this code. $gethandle = "C:\File1.exe" FileClose($gethandle) $gethandle = "2.exe" FileClose($gethandle) ProcessClose("C:\File1.exe") ProcessClose("2.exe") but this one is not working, or maybe i could not understand it. anyone please explain... someone also told to use Computer Info UDF's but i am not expert. please help. many thanks in advance. Edited August 18, 2008 by zFrank [font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php$Life = "Happy" If @Error Then $Life = "Risk"
Joscpe Posted August 18, 2008 Posted August 18, 2008 try this: $process=WinGetProcess("WindowTitle") ProcessClose($process) $gui=guicreate("WindowTitle") The first two lines would go before your GUI creation as shown and change "WindowTitle" to what ever you have your title set as. -Joscpe
zFrank Posted August 18, 2008 Author Posted August 18, 2008 thanks, but all the windows have same name. then how can i do it? [font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php$Life = "Happy" If @Error Then $Life = "Risk"
Joscpe Posted August 18, 2008 Posted August 18, 2008 (edited) Since you are creating your window afterwards it won't delete itself. Also, it will only remove one.Edit:Oh, you mean so it wont close one when you are loading up the second.Let me think a min, I've been up for 28 hours...Edit:How bout this:$win=WinList("WindowTitle") If $win[0][0] >= 4 Then For $i = 1 To 2 $process=WinGetProcess($win[$i][0]) ProcessClose($process) Next EndIf $gui=guicreate("WindowTitle") Edited August 18, 2008 by Joscpe -Joscpe
Moderators SmOke_N Posted August 18, 2008 Moderators Posted August 18, 2008 (edited) Use ProcessList("Process.exe"), enum through with a loop, and use _ProcessGetPath() to get the path of the executable. If the path matches what you want to remove then processclose(process identifier). Now ... _ProcessGetPath is not in the help file, so your script would look something like:Local $s_Exe = "Notepad.exe" Local $a_pl = ProcessList($s_Exe) Local $s_remove_destination = @HomeDrive & "\SomeWeirdPlace\" & $s_Exe For $i = 1 To $a_pl[0][0] If _ProcessGetPath($a_pl[$i][1]) = $s_remove_destination Then ProcessClose($a_pl[$i][1]) EndIf Next Func _ProcessGetPath($v_pid) If IsString($v_pid) Then $v_pid = ProcessExists($v_pid) If $v_pid = 0 Then Return SetError(1, 0, 0) Local Const $MAX_PATH = 260 Local Const $_Access = BitOR(0x0020, 0x0010, 0x0400) Local $h_process = DllCall("Kernel32.dll", "long", "OpenProcess", "dword", $_Access, "int", 0, "dword", $v_pid) If @error Then Return SetError(2, 0, 0) Local $t_path = DllStructCreate("char Path[" & $MAX_PATH & "]") Local $p_path = DllStructGetPtr($t_path) Local $a_modulename = DllCall("Psapi.dll", "long", "GetModuleFileNameEx", "long", $h_process[0], "int", 0, "ptr", $p_path, "int", $MAX_PATH) Local $n_error = @error DllCall("Kernel32.dll", "int", "CloseHandle", "long", $h_process[0]) If $n_error Then Return SetError(3, 0, 0) Return DllStructGetData($t_path, "Path") EndFunc Edited August 18, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
zFrank Posted August 18, 2008 Author Posted August 18, 2008 @ SmOke_N Thanks a lot sir, it really helped me a lot. keep the good work up! Bye [font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php$Life = "Happy" If @Error Then $Life = "Risk"
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