Removing an application using a command or script

sparrowhawk
New Contributor III

We have an application installed on all of our Macs called Egnyte Connect which we want to remove. This application was deployed using a pkg via JAMF. Egnyte have given us a command to run their uninstaller.

sudo /Applications/Egnyte\ Connect.app/Contents/Resources/Egnyte\ Connect\ Uninstaller.app/Contents/MacOS/Egnyte\ Connect\ Uninstaller

 How can I use this command in JAMF? I tried using it in a script but that didn't work.

#!/bin/bash

sudo /Applications/Egnyte\ Connect.app/Contents/Resources/Egnyte\ Connect\ Uninstaller.app/Contents/MacOS/Egnyte\ Connect\ Uninstaller

What's the best way to approach this?

Thanks

11 REPLIES 11

sdagley
Esteemed Contributor II

@sparrowhawk When running via Jamf Pro you can omit the sudo as Jamf will already be running the command as an admin.

Since it's a single command to run the uninstall easiest way to run would be via the Execute Command entry in a Files & Processes payload of a Policy. The escaping of the path for the uninstaller looks good, so if that doesn't work please post the log when running the policy so any error it's reporting can be identified.

sparrowhawk
New Contributor III

Hi @sdagley , thanks for your post! I've learned something new here already. I wasn't aware of the Files & Processes ability to run a command, so thanks! I set that up and although it ran the command, the application wasn't removed and there was no result recorded.

Screenshot 2023-09-07 at 15.17.41.png

Have I set it up incorrectly?

Screenshot 2023-09-07 at 15.22.42.png

sdagley
Esteemed Contributor II

@sparrowhawk Can you try running the command from Terminal on a Mac with the software installed and see if that works? (you'll need to include the sudo for that) And if it doesn't is there any additional information reported when you run the uninstaller that way?

sparrowhawk
New Contributor III

I've already tested that and it works when run locally.

sdagley
Esteemed Contributor II

What happens if you run the uninstaller without the sudo? And are all of your user accounts Admin accounts, or are they Standard accounts?

sparrowhawk
New Contributor III

Do you mean run the command locally without sudo? Our standard accounts aren't admins.

mm2270
Legendary Contributor III

If I had to guess, this command probably only works in a user context, since it's an executable from the app bundle. It probably launches an app that needs to be responded to to complete the uninstallation. Some other apps work this way too, like the uninstaller for Cisco AnyConnect.
Is that the case when you run it locally on a device instead of from a Jamf Pro policy?

sdagley
Esteemed Contributor II

@sparrowhawk Any response to @mm2270 's question regarding user interaction when running the uninstaller locally? That would definitely impact attempting to run the removal via a script.

sparrowhawk
New Contributor III

Hi @sdagley  and @mm2270, I've been on leave for a few days. The command runs silently and doesn't require any user interaction.

Deku91
New Contributor III

Hi,

try this as script

#!/bin/bash

# Check if Egnyte Connect is installed
if [ -e "/Applications/Egnyte Connect.app" ]; then
# Uninstall Egnyte Connect
sudo /Applications/Egnyte\ Connect.app/Contents/Resources/Egnyte\ Connect\ Uninstaller.app/Contents/MacOS/Egnyte\ Connect\ Uninstaller
echo "Egnyte Connect has been uninstalled."
else
echo "Egnyte Connect is not installed on this system."
fi

exit 0


sparrowhawk
New Contributor III

Hi @Deku91, you've cracked it! I just had to add a pkill "Egnyte Connect" as the application can't be running and setting the script to launch at login wasn't quick enough. The notifications didn't pop up, but I'm not worried about those.

Thanks all. I love JAMFNation, you guys rock! 🤘