Post Install SH Script Fails

KyleEricson
Valued Contributor II

I'm trying to make the Office 2016 Items show up on the dock via a post install script. I want to use Apple's built in tool. I run the following command in terminal and it works. I then that it and place it in the post install script and it doesn't do anything.

SH Script:

!/bin/sh

postinstall

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Word.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft PowerPoint.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Excel.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft OneNote.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Outlook.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Lync.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

killall Dock

Read My Blog: https://www.ericsontech.com
3 REPLIES 3

thoule
Valued Contributor II

Because it is running as root when it installs via policy so it's trying to modify root's dock. You need to either run as user, or address the user's dock.

KyleEricson
Valued Contributor II

How do I run this as the current user?

Read My Blog: https://www.ericsontech.com

thoule
Valued Contributor II

There are many many posts about that process. so I won't replicate here. Give one a try. You'll need to find out who the logged in user is, then 'sudo' as that username.