Scripting the Recent Items item under the apple menu

Here is what I tried, thanks to Kai:

my ClearRecentItemsMenu()

on ClearRecentItemsMenu()
	try
		set p to POSIX path of (path to preferences) & "com.apple.recentitems.plist"
		
		tell application "System Events"
			
			tell property list file p to repeat with i in {"Documents", "Applications", "Servers"}
				set value of property list item "CustomListItems" of property list item i to {}
			end repeat
			
			-- restart (* or shut down *)
			
		end tell
	end try
end ClearRecentItemsMenu

I had 3 apps, 2 docs and 0 servers visible in the Recent Items menu. One of the apps was “Pref Setter” and one of the docs was “com.apple.recentitems.plist”, with this plist closed within “Pref Setter”.

I then ran this script while in Script Editor. NO change in what was visible in the Recent Items menu. I then opened the plist file within Pref Setter and found 0 apps, 0 docs and 0 servers.

However, I then continued to write this message and 5 minutes or so later while composing, I then returned to Pref Setter and the magic plist and found 3 apps, 2 docs and 0 servers.

Thanks to all of you, I have learned bunches – Thanks for all your joint patience in this pursuit.