Hi,
Since none of the users on our computer have no admin rights, but we have created a possibility that the user can uninstall App. However, the script only deletes the application from the folder. That is sufficient in most cases. However, in some cases it is necessary to delete the created data. Maybe someone has an idea how to find these and delete them.
#!/bin/bash
##########################################################################
# Shellscript : Uninstall Script
# Autor : Andreas Vogel,
##########################################################################
# Script asks for the file to be deleted.
#
# Only for test - comment out in production!
# set -x
###### please only edit here
###### list files to protect here
app_protect="
NoMAD
McAfee
Self Service
Preproxy
Identity Agent
jamf"
##### End ################
# Variabeln
sys=$(while read p; do echo "$p" | grep "/Applications" ; done </System/Library/Sandbox/rootless.conf)
list="
$app_protect
$sys"
askapp () {
/usr/bin/osascript <<EOF - 2>/dev/null
set strPath to POSIX file "/Applications/"
set f to (choose file with prompt "$1" default location strPath)
set posixF to POSIX path of f
tell application "Finder" to set filesDir to container of f as alias as text
set posixDir to POSIX path of filesDir
posixF
EOF
}
asknewdir () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "")
end tell
EOF
}
app=$(askapp 'Please select the program to be deleted') || exit
# Loop for checking before deleting
for a in $list ; do
if [[ "$app" = *$a* ]]; then
osascript -e 'display dialog "This program can not be deleted!" buttons {"OK"} default button 1'
exit 0
fi
done
# Program is stopped and deleted
pkill -f "$app"
sudo rm -rf "$app"
osascript -e 'display dialog "The app has been deleted" buttons {"OK"} default button "OK"'
exit 0