Posted on 03-07-2017 09:44 AM
I'm using the Sierra OS. I'm trying to run a script for hiding the menu bar on a few systems. I'm using the following as my script:
#!/bin/sh
defaults write NSGlobalDomain _HIHideMenuBar -bool true
killall Finder
It says that it runs without any error but the result does not hide the menu bar or even toggle the "Automatically hide and show the menu bar" option under General in System Preferences. If I run the command locally, it works just fine. Is there some issue with doing this remotely? Is there something I'm missing?
Posted on 03-07-2017 09:46 AM
Posted on 03-07-2017 10:21 AM
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
Posted on 03-07-2017 05:15 PM
@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
Posted on 01-16-2018 09:37 AM
@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...
Posted on 05-07-2018 07:51 AM
What about using the defaults write in files and processes?
Posted on 07-30-2018 07:13 PM
@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