Files
Alte_Skripte/aktuelle_Scripte/uninstall_Application_2.0 2.sh
Andreas Vogel 306149a726 test
2026-02-16 15:28:29 +01:00

62 lines
1.3 KiB
Bash

#!/bin/bash
##########################################################################
# Shellscript : Uninstall Script
# Autor : Andreas Vogel,
##########################################################################
app_protect="
Jamf Connect
"
##### 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