Posted on 12-17-2019 08:15 AM
Trying to create a script (python or bash) to push out in a policy via Jamf Pro to delete Google Chrome.app from a system. I've tried various scripts online (new to scripting sorry) and everything fails. I'm currently testing this script and trying to run it manually using bash chrome-uninstall.sh but it keeps saying command not found. What am I doing wrong?
#!/bin/bash
# Remove Chrome
rm -rf /Applications/Google Chrome.app/
exit 0
Solved! Go to Solution.
Posted on 12-17-2019 12:43 PM
Hi,
You can upload script below into Jamf Pro to use within policies and using Parameter 4 to set the application name or using Jamf Remote to remove an application.
#!/bin/bash
# This script can delete apps that are sandboxed and live in /Applications
# The first parameter is used to kill the app. It should be the app name or path
# as required by the pkill command.
applicationPath="$4"
if [[ -z "${applicationPath}" ]]; then
echo "No application specified!"
exit 1
fi
## Closing Application
echo "Closing application: ${applicationPath}"
pkill "${applicationPath}"
## Removing Application
echo "Removing application: ${applicationPath}"
rm -rf "/Applications/${applicationPath}.app"
exit 0
Posted on 10-27-2020 02:23 AM
@ayotec Else something should work;
#!/bin/bash
# This script can delete apps that are sandboxed and live in /Applications
# The first parameter is used to kill the app. It should be the app name or path
# as required by the pkill command.
# the second parameter is used for removing a preference file / any file if specified.
applicationPath="$4"
plistPath="$5"
if [[ -z "${applicationPath}" ]]; then
echo "No application specified!"
exit 1
fi
## Closing Application
echo "Closing application: ${applicationPath}"
pkill "${applicationPath}"
## Removing Application
while [ -d /Applications/${applicationPath}.app ];
do
echo "${applicationPath} does exist, going to remove it."
rm -rf "/Applications/${applicationPath}.app"
sleep 1;
done;
echo "${applicationPath} does not exist, nothing to remove"
sleep 1;
## Removing preference file if specified
if [ -f "${plistPath}" ]; then
echo "${plistPath} found.. removing"
rm -f "${plistPath}"
fi
exit 0
Posted on 12-17-2019 10:40 AM
How about this?
Posted on 12-17-2019 12:43 PM
Hi,
You can upload script below into Jamf Pro to use within policies and using Parameter 4 to set the application name or using Jamf Remote to remove an application.
#!/bin/bash
# This script can delete apps that are sandboxed and live in /Applications
# The first parameter is used to kill the app. It should be the app name or path
# as required by the pkill command.
applicationPath="$4"
if [[ -z "${applicationPath}" ]]; then
echo "No application specified!"
exit 1
fi
## Closing Application
echo "Closing application: ${applicationPath}"
pkill "${applicationPath}"
## Removing Application
echo "Removing application: ${applicationPath}"
rm -rf "/Applications/${applicationPath}.app"
exit 0
Posted on 04-29-2020 10:32 AM
Worked perfect, thank you!
Posted on 04-29-2020 11:57 AM
Thank you @txhaflaire, this is really helpful. I haven't revisited this for some time. I had other ways to accomplish this. This is certainly simpler and can be reused for a few things I am sure. Thank you.
Posted on 10-27-2020 01:41 AM
@txhaflaire Thanks for the script. Really good. Is there a way we can also remove the plist file along with the application ?
Thanks
Posted on 10-27-2020 01:50 AM
@ayotec Which plist do you mean ? can you provide location? thanks!
Posted on 10-27-2020 02:23 AM
@ayotec Else something should work;
#!/bin/bash
# This script can delete apps that are sandboxed and live in /Applications
# The first parameter is used to kill the app. It should be the app name or path
# as required by the pkill command.
# the second parameter is used for removing a preference file / any file if specified.
applicationPath="$4"
plistPath="$5"
if [[ -z "${applicationPath}" ]]; then
echo "No application specified!"
exit 1
fi
## Closing Application
echo "Closing application: ${applicationPath}"
pkill "${applicationPath}"
## Removing Application
while [ -d /Applications/${applicationPath}.app ];
do
echo "${applicationPath} does exist, going to remove it."
rm -rf "/Applications/${applicationPath}.app"
sleep 1;
done;
echo "${applicationPath} does not exist, nothing to remove"
sleep 1;
## Removing preference file if specified
if [ -f "${plistPath}" ]; then
echo "${plistPath} found.. removing"
rm -f "${plistPath}"
fi
exit 0
Posted on 06-21-2024 07:20 AM
Thank you @ThijsX ! This is going to save me a lot of time!