Step 1 – Create the Shell Script.
1.1 First create a shell script file(test.sh) .
1.2 Write the code for deleting all the files belonging to your application in the shell script file,
1.3 Set the necessary privilege to “test.sh” file”.
-> sudo rm -rf /Applications/TestApp.app
-> sudo rm -rf /Library/Preferences/Menus.plist
-> sudo rm -rf /Library/Preferences/tes.reports.plist
-> sudo rm -rf /Applications/TestApp/Data
Step 2 – Create the AppleScript application using XCode
Step 3 – Add two buttons “UnInstall & Cancel” and write this code in the apple script file.
--launched application delegate method.
on launched theObject
tell window 1 -- This was created by Interface builder in XCode
set title of button "button1 " to "UnInstall" --Set the UnInstall button title
set title of button "button2" to "Cancel" --Set the Cancel button title
--UnInstall Button Click Action.
on clicked theObject
if title of theObject = "Cancel" then --Cancel button Click Action.
else if title of theObject = "UnInstall" then --Uninstall button Click Action.
--Find the path of "Application/Contents/Resources"
set hiddenscriptpath to (((path to me) as text) & "Contents:Resources:UnInstaller.sh")
set hiddenscriptpath to POSIX path of hiddenscriptpath
set qtdhiddenscriptpath to quoted form of hiddenscriptpath
-- Kill the Test.app
tell application "System Events"
if (get name of every application process) contains "test" then
tell application "Test" to quit
set command to "open " & qtdhiddenscriptpath
do shell script qtdhiddenscriptpath administrator privileges "YES" -- This is important only if your script needs Admin rights.
--Quit the application after uninstallation.
quit -- We are done Uninstalling , Exit here.
--Cancel Button Action.
on quit theObject
tell window 1
Step 4 – Copy the shell script file and past in the following path “TestApp.app/Contents/Resources”
Step 5 – Run the Test.app.