Posted on 05-09-2017 06:32 AM
We are trying to execute the following commands to Autohide the Menu Bar when the Mac logs in automatically as Guest.
#!/bin/sh
defaults write NSGlobalDomain _HIHideMenuBar -bool true
killall Finder
When we run this from either a script on JSS or from Files and Processes as a policy, it claims to execute but the bar is not hidden. The only way we can get this to work is to put the script file on the computer in the shared users folder and then have JSS run that file on the Mac. While this works, we would really like to find a way to do this without copying a file out to all the systems we use with this feature.
Any ideas?
Posted on 05-09-2017 07:18 AM
Hey mcoulter,
You may have to run that command as the user, in proper format. I believe this change is due to SIP. Anyways, I usually use something like this:
#!/bin/sh
currentUser=$(stat -f%Su /dev/console)
userUID=$(/usr/bin/dscl . read /Users/$currentUser UniqueID | awk {'print $2'})
launchctl asuser $userUID /usr/bin/defaults write NSGlobalDomain _HIHideMenuBar -bool true
killall cfprefsd
killall finder
I kill cfprefsd when making changes to Prefs plist, so that the OS will re-read from file the new plist settings. Instead of reading from cache.
I hope this helps
Thanks
Shawn OG
Posted on 05-10-2017 11:56 AM
OK, I'm so close and on the right track here. I've used the following:
#!/bin/sh
currentUser=$(stat -f%Su /dev/console)
userUID=$(/usr/bin/dscl . read /Users/$currentUser UniqueID | awk {'print $2'})
launchctl asuser $userUID /usr/bin/defaults write NSGlobalDomain _HIHideMenuBar -bool true
killall cfprefsd
killall Finder
...but the command 'killall' gets the error 'No matching processes were found'.