The solution is to create a LaunchAgent (
man launchctl for more info) that runs the above script via the command-line. Essentially, you want to store the script above in a file, say 'killfinder.scpt' and then run the command
We want to do this automatically at login, so we use a LaunchAgent. Since I want to use this because I use Pathfinder and my wife doesn't, I'm going to put it in
~/Library/LaunchAgents, but if you want this to be system wide, put it in
You will have three files:
- A UNIX script
- An AppleScript (optional)
- A LaunchAgent XML plist
- Put this in an appropriate path. For example, I stored it in
Create the file and add this content:
Make sure the permissions are correct (i.e.
chmod ug+x killfinder.bash)
You can call osascript directly with AppleScript code as an argument. I leave that as an exercise to the reader; in that case, you can creating this file. But if you want to do it this way:
1. Put this in an appropriate path.
2. Create the file and add this content:
tell application "System Events"
tell UI element "Finder" of list 1 of process "Dock"
perform action "AXShowMenu"
click menu item "Remove from Dock" of menu 1
- Make sure the permissions are correct (i.e.
chmod ugo+r Finder\ Remove.scpt)
LaunchAgent XML plist
Put this in
/Library/LaunchAgents depending if you just want this behavior for your personal account or system-wide.
Create a file called
com.<whateveryouwant>.KillFinder.plist with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
It's important to make sure the 'string' value after the
Label key is correct as well as the path to the unix script.
Now all you have to do is exit and login and it should work!