You are not logged in.
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-
Applescript:
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
Applescript:
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
Last edited by gostavs (2014-09-04 07:40:25 am)
Offline
Hi,
the main issue is the Finder works only with HFS paths (colon separated).
The HFS path equivalent is
Applescript:
set systemLibaryFolder to path to library folder from system domain
set localLibaryFolder to path to library folder -- local domain is the default value
set localApplicationSupportFolder to path to application support folder -- local domain is the default value
set localPreferencesFolder to path to preferences folder from local domain
tell application "Finder"
if exists folder "Java:JavaVirtualMachines" of systemLibaryFolder then delete folder "Java:JavaVirtualMachines" of systemLibaryFolder
if exists folder "Java:JavaVirtualMachines" of localLibaryFolder then delete folder "Java:JavaVirtualMachines" of localLibaryFolder
if exists folder "oracle" of localApplicationSupportFolder then delete folder "oracle" of localApplicationSupportFolder
delete (every item of localPreferencesFolder whose name starts with "com.oracle") -- exists is not necessary using a where clause
delete (every item of folder "var:db:receipts" of startup disk whose name starts with "com.oracle")
end tell
regards
Stefan
Offline
Hi,
Also, if you try to delete System files you need to enter an admin password. You might try unix' rm with sudo. Then, I think you only need to enter it once and it lasts for a short time.
gl,
kel
Os 10.10.3
Mbp
Offline