I have upgraded version of application. i want to remove old version from all user's also from Dock and install new version. package name is Yammer. and that is not pkg file. this is .app. old package location is ~/Application folder. i want to place new package to /Application for all user's. using below preinstall script for remove application. it is removing app for all users but yammer icon still in Dock showing. once i click on that showing question mark. tell me where i'm doing wrong.
dockutil --remove 'Yammer'
for i in /Users/*
do if [ -f $i/Applications/Yammer.app/Contents/MacOS/Yammer ] then rm -rf $i/Applications/Yammer.app fi
You'd have to run the dockutil command in a loop to for all user's home folders to remove Yammer from each person's dock, or use the --allhomes option. This will only remove Yammer from all docks, not replace it with the new path. If you wanted to replace it with the new path you might need to loop another dockutil command after installation to add Yammer back like so:
# You'd do this for each user. dockutil --add /Users/USERNAME/Applications/Yammer.app
I could go into more detail but you might be able to write the script with what I've provided.
@sidharth.bhalla On second thought, I figure I'd help more. Here you go.
#!/bin/bash # https://www.jamf.com/jamf-nation/discussions/31175/remove-question-mark-from-dock userList=$(find /Users -type d -maxdepth 1 -mindepth 1 | grep -v Shared) killall 'Yammer' for userHome in $userList; do if [[ -e "$userHome/Applications/Yammer.app" ]]; then echo "Yammer.app found in $userHome/Applications; deleting." /bin/rm -Rf "$userHome/Applications/Yammer.app" else echo "No Yammer.app installed in $userHome; skipping." fi dockutil --remove 'Yammer' --no-restart "$userHome" 2> /dev/null done killall Dock exit 0