Skip to main content
Question

Is it possible to manage preferences for sandboxed/containerized apps?

  • May 4, 2015
  • 5 replies
  • 39 views

bpavlov
Forum|alt.badge.img+18

As the subject states, is it possible to manage preferences for sandboxed/containerized apps? For example, Microsoft Remote Desktop from the App Store now stores its preferences in ~/Library/Containers/com.microsoft.rdc.mac/Data/Library/Preferences/com.microsoft.rdc.mac.plist

because its a sandboxed app. Short of manually modifying the plist file, any other options?

5 replies

stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • May 4, 2015

@bpavlov with RDC in particular, what are you trying to manage? If you are trying to create connections, yes, you can do that. @bentoms has a write up on his web site about it:

Remote Destkop 8 Connections

I personally use a modified method:

#!/bin/sh

loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

# global
RDCPLIST=/Users/$loggedInUser/Library/Containers/com.microsoft.rdc.mac/Data/Library/Preferences/com.microsoft.rdc.mac.plist
myUUID=`uuidgen`
LOGPATH='<yourlogpath>'

# set variables
connectionName="<nameoftheconnection"
hostAddress="<addressfortheconnection>"

# if you need to put an AD domain, add it to userName below
userName=''
# AD domain plus logged in user
userName+=$loggedInUser

resolution="1280 1024"
colorDepth="32"
fullScreen="FALSE"
scaleWindow="FALSE"
useAllMonitors="TRUE"

set -xv; exec 1> $LOGPATH/rdcPlist.txt 2>&1

defaults write $RDCPLIST bookmarkorder.ids -array-add "'{$myUUID}'"
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.label -string "$connectionName"
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.hostname -string $hostAddress
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.username -string $userName
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.resolution -string "@Size($resolution)"
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.depth -integer $colorDepth
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.fullscreen -bool $fullScreen
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.scaling -bool $scaleWindow
defaults write $RDCPLIST bookmarks.bookmark.{$myUUID}.useallmonitors -bool $useAllMonitors

chown -R "$loggedInUser:staff" /Users/$loggedInUser/Library/Containers/com.microsoft.rdc.mac

bpavlov
Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • May 4, 2015

It was more of a general question as to whether there was a BETTER way to do it. I happened to just use Microsoft Remote Desktop because it was a simple app that I was just dealing with at the time of my post. Actually I wasn't trying to create connections, but rather skip the first prompt window you get when opening it up.

It looks like there isn't a better way short of writing to the plist file using defaults. That works for me. Just wish Apple made profiles "containers"-aware. Oh well. Thanks for the post. Definitely interesting to read the script and see what others are doing.


Forum|alt.badge.img+1
  • New Contributor
  • November 5, 2015

On a side note, does anyone know of a way to restrict passwords from being saved in connections?


Forum|alt.badge.img+5
  • New Contributor
  • April 22, 2016

About manipulating preferences for a sandboxed app, in my experience you don't need to care that it's sandboxed for the purposes of getting/setting prefs. Simply defaults write com.microsoft.rdc.mac <key> <value> sets the key (eventually) in the container plist, and the preferences subsystem knows whether the app is sandboxed or not.


davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • April 22, 2016

@Widner the two ways that may work would be to write the setting at login defaults write... as @timsutton said, then a defaults delete... at logout.

Alternatively, delivering the setting via a config profile, although that may affect other connections they have setup.

Just ideas though. Nothing tested or proven :)