PDA

View Full Version : Kill a process


FoxLeader
10-12-2007, 01:56 PM
Hello,

I looked at some exemples and said "Cool! That's simple". But I tried and got... nothing. It's probably due to the table colums, which I don't know. So the code:

-- Get the titles and window handles of all open windows.
windows = Window.EnumerateProcesses();

-- A variable containing text in the title you want to search for.
window_name = "Apache.exe";

-- Loop through the table of windows.
for handle, title in windows do

-- Check if the window title has the target text.
result = String.Find(title, window_name, 1, false);

-- if the string was found in the title, send the window a close message.
if (result ~= -1) then
Window.Close(handle, CLOSEWND_SENDMESSAGE);
end
end

I think you undertsood I wanted to kill the process named "Apache.exe". So does anybody sees the error?
Thanks!

RizlaUK
10-12-2007, 03:34 PM
i think when referring to a process, it all has to be lowercase, give it a shot

FoxLeader
10-12-2007, 03:45 PM
Ok, thanks, will try this ;)

dragonw
10-13-2007, 10:53 AM
Easy use this in Dos command

TASKKILL /?

RizlaUK
10-13-2007, 11:18 AM
why would you want to use a dos command when ams already has a command (which uses the winAPI) to handle such a task


Window.Close(handle, CLOSEWND_TERMINATE);