@machattan
I suggest using the Dock Items Payload within a Policy to remove the app.
Located in Jamf Pro Dashboard -> Settings -> Computer Management -> Dock Items
Add your App as depicted below. Then Create a policy with the dock items payload, select your app that you just added & test removing.

If the path shown in your script above is indeed the location of the application, the path will be as follows.
Path: file:///Applications/BarcodeForVerification2021/Barcode%20x14.app/
@machattan
I suggest using the Dock Items Payload within a Policy to remove the app.
Located in Jamf Pro Dashboard -> Settings -> Computer Management -> Dock Items
Add your App as depicted below. Then Create a policy with the dock items payload, select your app that you just added & test removing.

If the path shown in your script above is indeed the location of the application, the path will be as follows.
Path: file:///Applications/BarcodeForVerification2021/Barcode%20x14.app/
@Hugonaut Thanks man! Actually, Dock Item was going to be my last resort. I've always been told to refrain from using the Dock Item option in policies. If i do use it, because it worked, how do i make it first or move it up in the policy list of executables? I have to put this all into a Self Service action for users.
#!/bin/zsh
dockutilbin='/usr/local/bin/dockutil'
loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name
&& ! /loginwindow/ { print $3 }' )
loggedInUserPlist="/Users/$loggedInUser/Library/Preferences/com.apple.dock.plist"
$dockutilbin --remove /Applications/BarcodeForVerification2021/Barcode\\ x14.app $loggedInUserPlist
sleep 1
killall cfprefsd
killall Dock
exit 0
maybe add no restart in there because the killall Dock is doing that
--no-restart
maybe add no restart in there because the killall Dock is doing that
--no-restart
@bizzaredm Thanks for this! I run the script locally, works! I try to run the script via Self Service (which is where this is all going), no good! SS just sits and spins... thoughts?
@bizzaredm Thanks for this! I run the script locally, works! I try to run the script via Self Service (which is where this is all going), no good! SS just sits and spins... thoughts?
Hi,
Try below. Hope that works out for you! :)
#!/bin/bash
# Get currently logged in user
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name
&& ! /loginwindow/ { print $3 }')
# Path to dockutil tool
dockutilPath="/usr/local/bin/dockutil"
/bin/launchctl asuser $(id -u $currentUser) $dockutilPath --remove "/Applications/BarcodeForVerification2021/Barcode x14.app" --no-restart
sleep 1
killall cfprefsd
killall Dock
exit 0
Hi,
Try below. Hope that works out for you! :)
#!/bin/bash
# Get currently logged in user
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name
&& ! /loginwindow/ { print $3 }')
# Path to dockutil tool
dockutilPath="/usr/local/bin/dockutil"
/bin/launchctl asuser $(id -u $currentUser) $dockutilPath --remove "/Applications/BarcodeForVerification2021/Barcode x14.app" --no-restart
sleep 1
killall cfprefsd
killall Dock
exit 0
Okay, getting closer! Thanks for this @KretZoR ! So now, the policy executes from SS. No more spinning wheel of what the heck?!?! But the Dock items doesn't get removed. I thought maybe it was the Dock item itself, so i tried changing the app to the Books.app. Just to see. Same thing. Dockutil command (--remove) is not removing the Dock item, for whatever reason. Thoughts?
You kind of overcomplicated this by using "file:///Applications/BarcodeForVerification2021/Barcode\\ x14.app". It should be as simple as this:
$dockutilbin --remove "Barcode x14.app" --restart $loggedInUserPlist
Dockutil is flexible in that it can take a full path or bundleid, but just using the label for removing it, meaning how it actually shows up in the Dock when you hover the cursor over it, is often sufficient.
You kind of overcomplicated this by using "file:///Applications/BarcodeForVerification2021/Barcode\\ x14.app". It should be as simple as this:
$dockutilbin --remove "Barcode x14.app" --restart $loggedInUserPlist
Dockutil is flexible in that it can take a full path or bundleid, but just using the label for removing it, meaning how it actually shows up in the Dock when you hover the cursor over it, is often sufficient.
@mm2270 I think we may have something here! Combined yours with the above and it seems to be working finally! Now to test with our end users. Thanks again!