Delete Specified items from the dock of a locked down computer

I am trying to find a way with applescript that will allow me to remove the dock icons of applications that I have deleted. I am not even sure if it is possible.

I would assume that it needs to be done as a shell script, but I am really not certain.

For example I want to delete an application from the dock that was already deleted from the hard drive entitled “Shutdown Now.app”. I was able to delete the application but I have not been able to have the same luck with the dock.

These are on locked down student computers and I have about 50 computers that I need to delete this one item from their docks. The problem is that the docks are also locked down so a student cannot add/remove/or delete dock items.


do shell script "command" user name "School Name" password "xxxxx" with administrator privileges

try
set itempaths to {"/Applications/Shutdown Now.app", "/Applications/Shutdown Now!.scpt"}

set command to "rm -rf " & quoted form of itempath
do shell script command with administrator privileges

--on error do nothing
end try
quit


So I guess I need to:

  1. unlock the dock
  2. delete the application icon from the dock
  3. lock the dock again

Thank you for your advice,
paulmattallen

In the persistent-apps-key of the com.apple.dock.plist-file you can find all the apps that are permanently in your Dock.

I don’t know how to loop through different items in a *.plist-file, let alone delete them.

Reveal your preferences file:

tell application "Finder" to reveal (((path to preferences folder) as text) & "com.apple.dock.plist")

Thanks, i will look into that.

Too bad it cannot be emulated like dragging the app off the dock and then having the dock correct its self. Like that automator feature. But you have to first unlock the computer then logout out, log back in and then drag the apps off the dock, change the admin settings log out. too many steps.

Thanks why I was looking for a simpler method.

Regards,
paulmattallen

Why don’t you make a template dock. And use a copy of its plist file to replace the original on the other Macs.
Heres an edit of a old script I have.

property labDocksPath : "/Users/UserName/Desktop/"
property plistName : "com.apple.dock.plist"
property userPrefsPath : "/Users/UserName/Library/Preferences/"

set src to labDocksPath & "/" & plistName
set dest to userPrefsPath & plistName
do shell script "ditto --rsrc " & src & " " & dest

--the delay gives the time for the new file to register
delay 1

--you most kill the dock if its running. This stops the ruuning dock from writing back to the new file before it picks up the new settings.
do shell script "killall Dock"

I am not sure how you are linking and running your scripts, but you could do this I assume by remote to the machines
via the command line, when no one is logged in.