简体   繁体   中英

How to kill all windowed processes in OS X

I was wondering if there's a way to kill all windowed processes, as displayed by selecting “Windowed Processes” in Activity Monitor, in Mac OS X (Lion 10.7.3) from bash .

That can be achieved pretty easily using AppleScript, specifically the Process Suite of System Events , which seems to have about the same notion of a windowed application as Activity Monitor :

tell application "System Events"
    set windowedAppIDs to bundle identifier of every process whose background only is false
    repeat with windowedAppID in windowedAppIDs
        tell application id windowedAppID to quit
    end repeat
end tell

To use this from the shell, wrap it in osascript -e (one -e option per line of AppleScript, mind the quoting and escaping. See man osascript ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM