Once per user policy to add dock item not working

chadlawson
Contributor
Contributor

Okay,

I've spent time RTFM'ing and banging my head into a wall, it's time to ask for help:

I am trying to make a policy that adds Self Service to the dock for every user. It either runs as part of the scheduled check-in or Self Service itself (for testing).

When the policy runs, the dock restarts as usual, but the item isn't there.

I actually now have two separate policies to add different items (one application, one document) to the dock and running as once per user, the same thing happens.

Oddly a similar policy I wrote I accidentally made as once per computer works normally.

I am running 9.2 and I have test computers running Mountain Lion and one Mavericks and they have the same behavior.

Anyone else having problems with once per user policies?

Chad Lawson

6 REPLIES 6

mm2270
Legendary Contributor III

Take a look here, as it may explain why its not working for you-
https://jamfnation.jamfsoftware.com/featureRequest.html?id=45

And then go get yourself a copy of the current version of dockutil, [(https://jamfnation.jamfsoftware.com/viewProduct.html?id=203&view=info]((https://jamfnation.jamfsoftware.com/viewProduct.html?id=203&view=info)) package and deploy it and write up a simple script that utilizes it to deploy your Dock icons. (Hint: there are some good examples of using dockutil here on JAMFNation)

While I'm a fan of most things in the Casper Suite, I really can't recommend using the built in Dock deployment method as its unreliable and too limited for most use cases.

nortonpc
Contributor

Not sure if this applies to you or not but we had this issue with Cisco's AnyConnect client, the application was in a subfolder. /Applications/Cisco/AnyConnect.app. I tried dockutil and jamf both, and never could get it to work every time.

Not sure if it was the subfolder or the app.

MrP
Contributor III

FWIW, I've found putting the following in the policy's "Files and Processes -> Execute command" seems to make things work. If something else is trying to configure when cfprefsd is refreshed, you might see funky results. Highly unlikely, but there is always the chance.

sleep 20; sudo killall -hup cfprefsd; sudo killall -hup Dock

edit:
If you have multiple policies to apply dock changes that will run at nearly the same time, stagger your sleep time. IE Policy 1: 20seconds, policy 2: 25 seconds, etc etc.

guidotti
Contributor II

Agreed with Dickson.
That is how we got it to work on my Jumpstart.
Note: Not actively using this feature.

davidacland
Honored Contributor II
Honored Contributor II

+1 for @mm2270 post

I've had inconsistent results using Casper to deploy Dock icons and normally use dockutil. Although where possible I try to get the users to learn how to manage the dock themselves.

It's a surprisingly difficult thing to remotely control reliably.

daz_wallace
Contributor III

In fact, here's a script I wrote a few days ago and am currently using (I have stripped out the sensitive stuff).

Script is set to an 'ongoing' 'login' policy, limited to the "all Staff" AD group for an education customer. It will nuke the existing Dock and replace it with this one at every login : )

#!/bin/bash

username="$3"
    if [ -z "$username" ]; then       # Checks if the variable is empty (user running script from Self Service)
        username="$USER"
    fi
echo "User: $username"
dockutil="/Library/Dockutil/dockutil"

su $3 -c "$dockutil --remove all"

su $3 -c "$dockutil --add '/Applications/Microsoft Office 2011/Microsoft Word.app'" 
su $3 -c "$dockutil --add '/Applications/Microsoft Office 2011/Microsoft Excel.app'"
su $3 -c "$dockutil --add '/Applications/Microsoft Office 2011/Microsoft PowerPoint.app'"
su $3 -c "$dockutil --add /Applications/iTunes.app/"
su $3 -c "$dockutil --add /Applications/Safari.app/"

su $3 -c "$dockutil --add /Applications --view grid --display folder"
su $3 -c "$dockutil --add /Users/Shared/[fullscreen cord file].rdp --label 'CoRD Full Screen'"
su $3 -c "$dockutil --add /Users/Shared/[Windowed cord file].rdp --label 'CoRD Window'"

su $3 -c "$dockutil --add '[webmail URL]' --label 'Staff Email'"
su $3 -c "$dockutil --add '[learning resource] ' --label '[name of resource]'"
su $3 -c "$dockutil --add '[Borough URL]' --label 'Web Portal'"

exit 0

As a bonus, I set a Casper MCX to make the dock immutable which stops GUI messing around with the dock, but works fine with DockUtil!

Credit to this thread: https://jamfnation.jamfsoftware.com/discussion.html?id=3738
and @jacob_salmela

Darren