Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Lokrado

macrumors regular
Original poster
Jan 26, 2009
210
0
Denmark
So I made this application to remove a known virus that comes with a cracked version of photoshop CS4, I personally don't have the virus myself. I was just making this tool based on integos press release.

Anyway I think my error is in the very first try, when it follows the error line down to the ok (quit) button, but the app continues t execute script further down causing unwanted dialogs

I would much appreciate any help on this concern, since this is my very first applescript! :)

Thank you! :)

Code:
set return_value to display dialog "Removing virus" with icon caution buttons {"Do it!", "No don't!", "Check manually"} default button 1 with title "Virus Remover"

set answer to button returned of return_value

if answer = "Do it!" then
	try
		try
			do shell script "rm /var/tmp/tmp.*" with administrator privileges
		on error
			try
				do shell script "rm /usr/bin/DivX*" with administrator privileges
			on error
				try
					do shell script "rm /System/Library/Startupitems/DivX*" with administrator privileges
				on error
					set return_value to display dialog "No virus found in subsequent directories!" with icon 2 buttons {"Ok"} default button 1 with title "Good!"
					
					set answer to button returned of return_value
					
					if answer = "Ok" then
						quit
					end if
				end try
			end try
		end try
		try
			do shell script "rm /usr/bin/DivX*" with administrator privileges
		on error
			try
				do shell script "rm /System/Library/Startupitems/DivX*" with administrator privileges
			on error
				set return_value to display dialog "Virus found and deleted in /var/tmp/ but none in subsequent directories" with icon 2 buttons {"Ok"} default button 1 with title "Partial success"
				set answer to button returned of return_value
				
				if answer = "Ok" then
					quit
				end if
			end try
		end try
		try
			do shell script "rm /System/Library/Startupitems/DivX*" with administrator privileges
		on error
			set return_value to display dialog "virus found and deleted in /var/tmp/ and /usr/bin but none in subsequent folders" with icon 2 buttons {"Ok"} default button 1 with title "Partial success"
			set answer to button returned of return_value
			
			if answer = "Ok" then
				quit
			end if
		end try
	on error
		set return_value to display dialog "Virus found and deleted in /var/tmp/, /usr/bin and /System/Library/Startupitems, you are safe for now!..." buttons {"Ok"} default button 1 with title "Success"
		set answer to button returned of return_value
		
		if answer = "Ok" then
			quit
		end if
	end try
else if answer = "Check manually" then
	do shell script "open /var/tmp"
	do shell script "open /usr/bin"
	do shell script "open /System/Library/Startupitems"
	set return_value to display dialog "In the folder /var/tmp/ the virus is an Unix executable (.exec) which name starts with tmp. then something random like: 0.4hs82h. In /usr/bin and /System/Library/Startupitems it is called 'DivX' that's sadly all I know" buttons {"Ok", "More Information"} default button 1 with title "Info"
	
	set answer to button returned of return_value
	
	if answer = "More Information" then
		tell application "Safari"
			open location "http://www.intego.com/news/ism0902.asp"
		end tell
	else
		quit
	end if
else
	quit
end if


edit, seems you would have to copy paste it into applescript editor to view it with markup.coloring....
 

sammich

macrumors 601
Sep 26, 2006
4,305
268
Sarcasmville.
Using the [ code ] [ /code ] tags would help as well.

That said, it would be easier to see the code markup/colouring in Applescript Editor...

EDIT: not sure if this helps, but maybe try 'stop' instead of 'quit.
 

Lokrado

macrumors regular
Original poster
Jan 26, 2009
210
0
Denmark
stop/quit

should do the same, when i run the script from the editor i get an error telling me i cant quit while its running, but that would still normally stop it...while running as an app it just continues...
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
You do realize there's already removal tools right? Why would you want to help pirates anyways?
 

Lokrado

macrumors regular
Original poster
Jan 26, 2009
210
0
Denmark
lol

yes i do and i don't care, it was simply the first thing i found that i could write an app for that wouldn't be completely useless, learning by doing so happens to be the way i learn.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.