bra033098
asked on
Delete folder from script
I need to write an uninstallscript for an application. The script needs to delete a folder in the /Applications folder and delete a file from /etc/mach_init_per_user.d/
I need this script to be run from finder using a double click, but can not seem to get it right.
I have a bash script that works, but of course when double clicking in finder I simply get "There is no default application specified to open the document 'uninstall'". I tried it in Applescript, but I am afraid Applescript is not something you pick up in 1 hour.
Can someone translate this bash script to Applescript, or can tell me how to get the bash script to run from finder.
Thanks
Bash script:
#!/bin/bash
killall monitorApp
rm -Rf /Applications/MyApp
echo Root password required to delete file.
sudo rm /etc/mach_init_per_user.d/ monitorApp .plist
I need this script to be run from finder using a double click, but can not seem to get it right.
I have a bash script that works, but of course when double clicking in finder I simply get "There is no default application specified to open the document 'uninstall'". I tried it in Applescript, but I am afraid Applescript is not something you pick up in 1 hour.
Can someone translate this bash script to Applescript, or can tell me how to get the bash script to run from finder.
Thanks
Bash script:
#!/bin/bash
killall monitorApp
rm -Rf /Applications/MyApp
echo Root password required to delete file.
sudo rm /etc/mach_init_per_user.d/
ASKER
BT
Thanks for the reply. So far so good. It works but there are some issues:
I need to distribute the script with an application, so I would not know the password for the machine it would be running on.
How do I make the little squigle after the "do shell script". My script works, but only because I moved killall to the end of the previous line.
Is there any way to ask the user to enter the admin password? (yes I know, very bad practice).
Finally, showing my ignorance as far as Mac and Applescript is concerned. When I save this txt file as uninstall.applescript, it only opens in Applescript Editor when I doubleclick it. I am clearly missing something very basic.
Thanks
Thanks for the reply. So far so good. It works but there are some issues:
I need to distribute the script with an application, so I would not know the password for the machine it would be running on.
How do I make the little squigle after the "do shell script". My script works, but only because I moved killall to the end of the previous line.
Is there any way to ask the user to enter the admin password? (yes I know, very bad practice).
Finally, showing my ignorance as far as Mac and Applescript is concerned. When I save this txt file as uninstall.applescript, it only opens in Applescript Editor when I doubleclick it. I am clearly missing something very basic.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
// you should have a file monitorApp.plist in the target location
//also you should change the password 12345 in this script by your password
with timeout of 1000 seconds
try
do shell script ¬
"killall monitorApp
rm -Rf /Applications/MyApp
sudo rm /etc/mach_init_per_user.d/
on error errormsg
display dialog errormsg --in case anything goes wrong
end try
end timeout
--BT