Skip to main content
Solved

Script Issue With Setting Finder Prefs


Forum|alt.badge.img+22
  • Honored Contributor
  • 289 replies

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.

!/bin/bash

Initial setup script for Mac OS X 10.10.x

Last modified 05.27.2015

Show icons for hard drives, servers, and removable media on the desktop

/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

Best answer by bpavlov

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.

View original
Did this topic help you find an answer to your question?

7 replies

donmontalvo
Forum|alt.badge.img+36
  • Legendary Contributor
  • 4293 replies
  • May 27, 2015

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

bpavlov
Forum|alt.badge.img+18
  • Esteemed Contributor
  • 1206 replies
  • Answer
  • May 27, 2015

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.


Forum|alt.badge.img+22
  • Author
  • Honored Contributor
  • 289 replies
  • May 27, 2015

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!


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • May 27, 2015
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.


Forum|alt.badge.img+22
  • Author
  • Honored Contributor
  • 289 replies
  • May 27, 2015

@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.


donmontalvo
Forum|alt.badge.img+36
  • Legendary Contributor
  • 4293 replies
  • May 27, 2015

@TomDay Must be nice having APNS...<sniffle>...

:)


Forum|alt.badge.img+10
  • Contributor
  • 72 replies
  • May 28, 2015

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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings