Uninstall Chrome

cjvautour
New Contributor

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
7 REPLIES 7

obi-k
Valued Contributor II

How about this?

41978ab66402420e93081a551d2a9680

ThijsX
Valued Contributor
Valued Contributor

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

b0f06e21fee84a2398408bb151c5cfeb

3d46e1411ee4438eb5cc73c687881627

cjvautour
New Contributor

Worked perfect, thank you!

mconners
Valued Contributor

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.

ayotec
New Contributor

@txhaflaire Thanks for the script. Really good. Is there a way we can also remove the plist file along with the application ?

Thanks

ThijsX
Valued Contributor
Valued Contributor

@ayotec Which plist do you mean ? can you provide location? thanks!

ThijsX
Valued Contributor
Valued Contributor

@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

deff4151c17b4b5e95a03cdb14d81f74