Noobie, need help deleting all default fonts

So this is my first applescript, but I’ve used other programing languages before …
I have written a script to delete the default fonts from the current users library. It works but “UI elements” must be enabled in order to grab the username, so I added a shell script to enable UI, but I cannot seem to be able to make it work after enabling “UI elements”
Here is my code …


tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preferences.users"
end tell
set user_name to ""
set pwd to "password"
tell application "System Events"
	if UI elements enabled then
		tell tab group 1 of window "Accounts" of process "System Preferences"
			click radio button 1
			delay 2
			copy value of text field 2 to user_name
		end tell
	else
		tell me to do shell script ¬
			"touch /private/var/db/.AccessibilityAPIEnabled" password ¬
			pwd with administrator privileges
		-- here is where I want it to do what is after the "then" statement above before disabling "UI elements" again, but if I simply copy the text here it does not work
		tell me to do shell script ¬
			"rm /private/var/db/.AccessibilityAPIEnabled" password ¬
			pwd with administrator privileges
	end if
end tell
tell application "System Preferences" to quit
try
	tell application "Font Reserve Client" to quit
end try
try
	tell application "Finder"
		activate
		select folder "Fonts" of folder "Library" of folder user_name of folder "Users" of startup disk
		set the selected_fonts to contents of selection
		delete selected_fonts
		tell folder "Library" of folder user_name of folder "Users" of startup disk to close
	end tell
end try

Any info would be greatly appreciated

Hi,

you can get the (long) user name with one line (only available in Tiger)

set user_name to long user name of (system info)

or for Panther with two lines

set user_short_name to system attribute "USER"
set user_full_name to (do shell script "finger " & user_short_name & " | grep Login | colrm 1 46")

Wow I feel sheepish!

New code …


set user_name to short user name of (system info)
try
	tell application "Font Reserve Client" to quit
end try
try
	tell application "Finder"
		activate
		select items of folder "Fonts" of folder "Library" of folder user_name of folder "Users" of startup disk
		set the selected_fonts to contents of selection
		delete selected_fonts
		tell folder "Library" of folder user_name of folder "Users" of startup disk to close
	end tell
end try

thanks for your input!

.still easier

try
	quit application "Font Reserve Client" 
end try
try
	tell application "Finder"
		delete (get items of (path to fonts from user domain))
		close folder (path to library folder from user domain)
	end tell
end try

Not mine but panther in 1 (I think.)

set UserLongName to do shell script "niutil -readprop . /users/" & (do shell script "whoami") & " realname"