Posted on 05-27-2015 10:06 AM
Sort of newbie here to scripting so looking for some help! I want to get the hard drive etc to show up on users desktops as they update to Yosemite or get a new computer with Yosemite. I'll include portion of the script below, I'm sure it's an easy fix, just need some knowledgeable eyes.
/usr/bin/defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
/usr/bin/defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
/usr/bin/defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
/usr/bin/defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
Solved! Go to Solution.
Posted on 05-27-2015 10:14 AM
Need some context. How is this script being run? Is it through a Casper policy? Is it something installed through a package locally through a postinstall script or through a launch daemon or a launchagent?
Just so you're aware these are settings that can be set easily via a Configuration Profile through Casper this way its managed all the time.
Computers tab -> Configuration Profiles -> New -> Add the Finder payload and select the options you want.
Posted on 05-27-2015 10:12 AM
Might want to killall cfprefsd and killall Finder it too.
#!/bin/sh
/usr/bin/defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true;
/usr/bin/defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true;
/usr/bin/defaults write com.apple.finder ShowMountedServersOnDesktop -bool true;
/usr/bin/defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true;
/usr/bin/killall cfprefsd;
/usr/bin/killall Finder;
echo "OMG we killed Finder!"
exit 0
Posted on 05-27-2015 10:14 AM
Need some context. How is this script being run? Is it through a Casper policy? Is it something installed through a package locally through a postinstall script or through a launch daemon or a launchagent?
Just so you're aware these are settings that can be set easily via a Configuration Profile through Casper this way its managed all the time.
Computers tab -> Configuration Profiles -> New -> Add the Finder payload and select the options you want.
Posted on 05-27-2015 10:25 AM
Thank you both, seems like the Config profile is the better option, feels like I'm making this harder than it needs to be with the script!
Posted on 05-27-2015 10:31 AM
these are settings that can be set easily via a Configuration Profile through Casper this way its managed all the time.
That little bit of info is important to keep in mind (emphasis added is mine). Unlike with older MCX, there isn't a way to set this once and then let the user decide on personal preference if they'd rather not see any HDs on the Desktop. Once set via Config Profile they cannot disable it. Just make sure you're OK with that.
Posted on 05-27-2015 10:40 AM
@mm2270 Thanks for the additional note, will keep this in mind for sure. Just starting off with a very limited basic profile, like the way the Finder is set for these users now.
Posted on 05-27-2015 11:05 AM
Posted on 05-28-2015 09:55 AM
To answer your original question, ALL scripts run as root. When using the defaults command you need to specify the exact Preference Domain. If you abbreviate–
/usr/bin/defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true;
It will make the change to the user running the command. In this case Root. You could run it as a login policy (the easiest way to run as user) and do something like:
su "$3" -c '/usr/bin/defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true'
Or modify the user template.