Checking whether (in in which variant) an application is installed

– Checking whether (and in which variant) an application is installed

To check whether an application is installed,
and if so which bundle identifier variant is installed,

(for example to locate its settings plist or cache),

and to do all this without forcing the app (if installed) to launch …

-- e.g.
-- OFOC OmniFocus
-- OGfl OmniGraffle
-- DNtp DEVONthink Pro
-- Scrv Scrivener
-- etc

property pstrCreatorCode : "OFOC"

on run
	if IsInstalled(pstrCreatorCode) then
		display dialog "Installed variant: " & BundleVariant(pstrCreatorCode)
	else
		display dialog pstrCreatorCode & " not installed"
	end if
end run

on IsInstalled(strCreatorCode)
	try
		tell application "Finder" to exists application file id strCreatorCode
	on error
		false
	end try
end IsInstalled

on BundleVariant(strCreatorCode)
	tell application "Finder" to id of application file id strCreatorCode
end BundleVariant