AppleScript to stop all processes can be stopped safely

This script lists all active processes and lists them. Since I often encode the movie I like using Handbrake, for better performance I need to, except for Handbrake, only those processes that cannot be deleted should be executed. Perhaps there is such a way to filter the most necessary processes. Please help if anyone knows.

tell application "Finder" to get the name of every process

→ {“loginwindow”, “ViewBridgeAuxiliary”, “universalaccessd”, “talagent”, “Dock”, “SystemUIServer”, “ViewBridgeAuxiliary”, “Finder”, “imklaunchagent”, “TISwitcher”, “AirPlayUIAgent”, “nbagent”, “com.apple.dock.extra”, “FolderActionsDispatcher”, “CoreLocationAgent”, “PAH_Extension”, “cloudphotosd”, “LaterAgent”, “HandBrake”, “SimulatorTrampoline”, “com.apple.CoreSimulator.CoreSimulatorService”, “studentd”, “WiFiAgent”, “NotificationCenter”, “garcon”, “Spotlight”, “Script Editor”, “Safari”, “com.apple.WebKit.Networking”, “com.apple.WebKit.Networking”, “com.apple.Safari.SandboxBroker”, “com.apple.WebKit.WebContent”, “com.apple.WebKit.WebContent”, “com.apple.WebKit.WebContent”, “CoreServicesUIAgent”, “com.apple.WebKit.WebContent”, “com.apple.WebKit.WebContent”, “System Events”}

You could try starting only with those stored in /Applications. You could also play with this:

use framework "Foundation"
use framework "AppKit"
use scripting additions

current application's NSRunningApplication's terminateAutomaticallyTerminableApplications()

But honestly, I suspect it’s going to make very little difference.

Very strange, but for some reason this code does not stop anything. The method documentation is very poor. Can anyone know how to apply this method?

I would like only those processes that work after restarting the computer to work. Of course, I can restart the machine, make manually a list of “necessary processes” seeing them after restarting, to “kill” then all processes not related to this list, but I would like to understand why the above method does not work for my purposes.

The reason would be that none of your running apps support automatic termination. You caan check their Info.plist files for NSSupportsAutomaticTermination.

I checked info.plist of Safari. It has this key and its value is true. However, the method still doesn’t terminate the Safari.app.

Maybe, exists somewhere system-wide setting which prevents to terminate process using the given method? Or, this method works only when installing (or updating) some app?

I don’t know any more than what the docs state. It’s possible that Safari is different these days because it launches sites as separate processes, or the documentation could simply be wrong or out-of-date. I think it’s one of those things that was brought over from iOS.

Thanks, Shane, for your answers. Let’s leave this question unresolved for now. Perhaps in the future, someone will shed some light on this puzzle.

In principle, it is not difficult for me to use the “semi-manual” method indicated above.