Any app: Get app Icon's reference with bundle ID

I am not sure, following handler is the best way to get icon file reference for chosen app.

At least, it doesn’t launch the app to do this simple task.


set appIconPath to my getAppIcon:(id of (choose application))

on getAppIcon:theID
	tell application "Finder" to set appHFS to (application file id theID) as text
	try
		set iconHFS to appHFS & ":Contents:Resources:" & (do shell script "defaults read '" & POSIX path of (appHFS & ":Contents:Info") & "' CFBundleIconFile")
		if iconHFS does not end with ".icns" then set iconHFS to iconHFS & ".icns"
		return iconHFS as alias
	end try
	return missing value
end getAppIcon: