Hi!
First off, Im almost completely new to this.
I want to make a script that deletes folders and files related to Java.
Ive googled and searched the forums. Ive come up with and tried different variations of these two scripts, and i dont understand why either dont work-
tell application "Finder"
if exists folder "/System/Library/Java/JavaVirtualMachines/" then delete ({POSIX file "/System/Library/Java/JavaVirtualMachines"} as alias)
if exists folder "/Library/Java/JavaVirtualMachines/" then delete ({POSIX file "/Library/Java/JavaVirtualMachines"} as alias)
if exists folder "/Library/Application Support/Oracle" then delete ({POSIX file "/Library/Application Support/Oracle"} as alias)
if exists file "/Library/Preferences/com.oracle*" then delete ({POSIX file "/Library/Preferences/com.oracle*"} as alias)
if exists file "/var/db/receipts/com.oracle*" then delete ({POSIX file "/var/db/receipts/com.oracle*"} as alias)
end tell
tell application "Finder"
if exists "/System/Library/Java/JavaVirtualMachines/" then delete "/System/Library/Java/JavaVirtualMachines"
if exists "/Library/Java/JavaVirtualMachines/" then delete "/Library/Java/JavaVirtualMachines"
if exists "/Library/Application Support/Oracle" then delete "/Library/Application Support/Oracle"
if exists "/Library/Preferences/com.oracle*" then delete "/Library/Preferences/com.oracle*"
if exists "/var/db/receipts/com.oracle*" then delete "/var/db/receipts/com.oracle*"
end tell
Both says that every folder dont exist and therefore it doesnt delete them. I almost got it working one time, but then I had to enter the admin password for every folder/file that was to be deleted.
I want to be able to run the script on my clients and enter the admin password once, and then be done with it. Any help is greatly appreciated!
Best regards,
Gustav