Ok I had this working then got all fancy and Now I can't get it to go


I want to delete the File “VSearch.Framework” but for some reason I can’t delete it any ideas Why Gang!

set FrameSup to theStartupdisk & “:” & “System:Library:Frameworks:” & “VSearch.Framework”

tell application “Finder”
if exists file FrameSup then
beep
delete file FrameSup
end if
end tell

Thanks BigJack

The last time you asked, the path was not this one.
It was :

set FrameSup to theStartupdisk & ":" & "Library:Frameworks:" & "VSearch.Framework"

The contents of the folder :
theStartupdisk & “:” & "System:Library
must never be changed by the user.

Yvan KOENIG (VALLAURIS, France) samedi 27 septembre 2014 11:05:35

PS : [b]One more time you used the balises wrongly.

Above, I used
[ a p p l e s c r i p t ]
set FrameSup to theStartupdisk & “:” & “Library:Frameworks:” & “VSearch.Framework”
[ / a p p l e s c r i p t ]
Here I inserted extraneous spaces to fool the message parser.[/b]

In this case it should be: VSearch is a malicious adware framework which installs itself without being asked.
Here is some information about it

So are you saying applescript can’t delete the file?

I posted again with 3 different types of code to delete it none worked.


-- Remove one adware file from /System/Library/Frameworks/VSearch.framework

property filesToDeleteFX : {"VSearch.Framework"}

repeat with aFile in filesToDeleteFX
	try
		do shell script "/bin/rm /System/Library/Frameworks/" & aFile with administrator privileges
	end try
end repeat


set FrameSup to theStartupdisk & ":" & "System:Library:Frameworks:" & "VSearch.Framework"

tell application "Finder"
	if exists file FrameSup then
		beep
		delete file FrameSup
	end if
end tell

try
	do shell script "rm /System/Library/Frameworks/VSearch.framework"
end try


This is just my 4th day working with AppleScript and I confused why I can’t delete this file are you saying it is in possible to do using the script? Thanks for any help!


set systemFrameworkFolder to POSIX path of (path to library folder from system domain) & "Frameworks/"
try
	do shell script "/bin/rm -r " & quoted form of (systemFrameworkFolder & "VSearch.Framework") with administrator privileges
end try

Edit: or easier


try
	do shell script "/bin/rm -r /System/Library/Frameworks/VSearch.Framework" with administrator privileges
end try

Stephan this did not delete the file either I ran it as posted by you.

set systemFrameworkFolder to POSIX path of (path to library folder from system domain) & "Frameworks/"

try
	do shell script "/bin/rm -r " & quoted form of (systemFrameworkFolder & "VSearch.Framework") with administrator privileges
end try

May I write that it would be useful to take care of what was already said in preceding answers ?

I wrote that your framework is not a file but a package so you must insert the option -R in the removing instruction.
In fact I wrote : insert -dr and DJ Bazzie Wazzie wrote that the option -R implies the -d one.

Here is an subset of the man page dedicated to rm :

[i] -d Attempt to remove directories as well as other types of
files.

 -f          Attempt to remove the files without prompting for confirma-
             tion, regardless of the file's permissions.  If the file does
             not exist, do not display a diagnostic message or modify the
             exit status to reflect an error.  The -f option overrides any
             previous -i options.

 -i          Request confirmation before attempting to remove each file,
             regardless of the file's permissions, or whether or not the
             standard input device is a terminal.  The -i option overrides
             any previous -f options.

 -P          Overwrite regular files before deleting them.  Files are
             overwritten three times, first with the byte pattern 0xff,
             then 0x00, and then 0xff again, before they are deleted.

 -R          Attempt to remove the file hierarchy rooted in each file
             argument.  The -R option implies the -d option.  If the -i
             option is specified, the user is prompted for confirmation
             before each directory's contents are processed (as well as
             before the attempt is made to remove the directory).  If the
             user does not respond affirmatively, the file hierarchy
             rooted in that directory is skipped.

 -r          Equivalent to -R.[/i]
property filesToDeleteFX : {"VSearch.Framework"}

repeat with aFile in filesToDeleteFX
   try
       do shell script "/bin/rm -R /System/Library/Frameworks/" & aFile with administrator privileges
   end try
end repeat

Works flawlessly.

I wish to add that the same DJ Bazzie Wazzie urged you to remove the try / end try instructions when a piece of code doesn’t work as you assume that it must be.
Doing that, you will get an error message which ” some times ” explains clearly what is wrong.

Here is what I got without the try / end try :

property filesToDeleteFX : {"VSearch.Framework"}

repeat with aFile in filesToDeleteFX
	
	do shell script "/bin/rm /System/Library/Frameworks/" & aFile with administrator privileges
	--> error "rm: /System/Library/Frameworks/VSearch.Framework: is a directory" number 1
end repeat

We are in a case where the error message is perfectly clear.

The try / end try instructions must not be used to mask coding oddities.

Yvan KOENIG (VALLAURIS, France) samedi 27 septembre 2014 11:50:07

This one worked

try
	do shell script "/bin/rm -r /System/Library/Frameworks/VSearch.Framework" with administrator privileges
end try

It’s foolish.
When I ran it, the code given by StefanK executed the instruction :

do shell script "/bin/rm -r '/System/Library/Frameworks/VSearch.Framework'" with administrator privileges

As there is no space in your pathname, it does EXACTLY the same thing than your :

do shell script "/bin/rm -r /System/Library/Frameworks/VSearch.Framework" with administrator privileges

So, if your version works ” what it did here ” the StefanK’s one works too ” what it did here.

Here is the complete event log issued when I ran the StefanK’s code ” the long one :

tell current application
	path to library folder from system domain
		--> alias "SSD 500:System:Library:"
	do shell script "/bin/rm -r '/System/Library/Frameworks/VSearch.Framework'" with administrator privileges
		--> ""
end tell

Yvan KOENIG (VALLAURIS, France) samedi 27 septembre 2014 12:28:15