If it's a user specific preference you'll have to run the script as the logged in user, not as your management account that the script would run from via Remote or Policy.
If this is the case, try something like this:
#!/bin/sh
user=`ls -la /dev/console | cut -d " " -f 4`
sudo -u $user defaults write NSGlobalDomain _HIHideMenuBar -bool true
sudo -u $user killall Finder
@kendalljjohnson i think the script wont work if the user is not a sudoer.
#!/bin/sh
curUser=`ls -l /dev/console | cut -d " " -f 4`
defaults write /Users/$curUser/Library/Preferences/ ..... instead
sudo killall Finder
@khey I used your script and it worked, however it removed all access to the script except for "system" and "everyone", with r+w and no access respectively. Once I added the admin group back in I was able to read/edit the plist but found it odd that it removed access.
Any ideas why?
edit: I checked the permissions in terminal and it now shows 'root' as the owner instead of my domain account. Wonder how it did that?
The script I used was:
#!/bin/sh
curUser=ls -l /dev/console | cut -d " " -f 4
defaults write /Users/$curUser/Library/Preferences/com.apple.desktopservices DSDontWriteNetworkStores TRUE
it works, just changes the ownership and access rights, weird...
What about using the defaults write in files and processes?
@slundy apology, i just read this....
Actually you can also use Config Profile to disable that by default to all user instead of using a script.
To do that, go to /Library/Preferences/"the plist you want to change"/ and copy the plist and edit it with TextWrangler or something. Find the key you want to set to True or False and save it.
Go to Configuration Profile - Custom Settings and upload the plist and push it out.
thanks