Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am trying to quit all the active browsers using the below code, but am unable to get the list of all active browsers to quit.

tell application "System Events"

    set appList to every process whose visible is true

    repeat with thisApp in appList
        tell process browser
            quit
        end tell
    end repeat
end tell
share|improve this question

2 Answers 2

tell application "System Events"
    set ProcessList to name of every process
    if "Safari" is in ProcessList then
        tell application "Safari"
            quit
        end tell
    end if
end tell

Repeat as needed

share|improve this answer

Assuming you know what browsers you have installed (and why wouldn't you?), there's no need to bother getting the processes, you can just loop through a list of browsers and send a quit message:

set browserList to {"Safari", "Google Chrome", "Firefox"}

repeat with browser in browserList
    tell application browser to quit
end repeat

Just make sure to edit browserList to include only the browsers you have installed, otherwise you'll get an AppleScript prompt asking you to locate the ones you don't.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.