Find Process and kill it

Hi All!

I need to write a script that will see if a certain process is running (either as a desktop, or as a console app), and quit it.

Help…anybody…:confused:

as an addendum, i’ve managed it for Desktop apps, but can’t find console apps yet. I copied and modified some code from another post, and my script is:


-- first, get all running apps:
tell application "System Events"
	-- find running apps
	set runningApps to name of every process
end tell

-- now loop through each application
repeat with eachApp in runningApps
	try -- here's the try statement
		tell application eachApp -- tell each app in turn
			if eachApp contains "Mail" then
				display dialog the eachApp
				quit eachApp
			end if
		end tell
	on error -- if the above statement fails...
		-- do nothing - just ignore the error and move on 
	end try
end repeat

now, what do I do for console apps?