Installing into an app's resource folder?

That was my assumption, too.

Hello

A point which was written about here gave the idea to ask about Contacts.

When I run the script posted below, the attempts to activate Contacts without its full pathname failed with an error #-10661. So I used the late instructions which use what is the standard path to this application.

Is there a cleaner way which I missed ?

tell application "Contacts"
	set ContactsIsRunning to running
end tell
log ContactsIsRunning
if ContactsIsRunning is false then
	try
		path to application "Contacts"
	on error errMsg number errNbr
		(*Une erreur de type -10661 est survenue.*)
		display dialog errMsg
	end try
	try
		tell application "Contacts" to launch
	on error errMsg number errNbr
		(*Une erreur de type -10661 est survenue.*)
		display dialog errMsg
	end try
	
	try
		tell application "Contacts" to activate
	on error errMsg number errNbr
		(*Une erreur de type -10661 est survenue.*)
		display dialog errMsg
	end try
end if

# Is there a better scheme than :
set p2Contacts to (path to applications folder as text) & "Contacts"

tell application "Finder" to open alias p2Contacts

Yvan KOENIG (VALLAURIS, France) jeudi 19 mars 2015 23:07:17

Couldn’t you simply use:

tell application "Finder" to open application file id "com.apple.AddressBook"

Unless your question is specific to opening via path/alias.

Thanks

I just forgot this syntax.

Yvan KOENIG (VALLAURIS, France) samedi 21 mars 2015 19:00:42

Whilst I realise it might be retrogressive to re-open an old topic but this was my topic and my script appears to be failing under OSX 10.11. I upgraded from OSX 10.6 (& minor computer upgrades) last month. Now running this script I find the following problem: Java applications are no longer recognised and listed on the list of applications to choose from, even though it does list applications not necessarily within the system drive’s Applications folder. Apple’s java 6 is installed & the Java apps open without issue.

tell application "Finder"
						
						try
							
							duplicate my hfile to folder apps_path with replacing --- installs hfile to Acq app folder
							
						on error --- this will occur if Acq is not installed in Applications folder, or is not installed at all
							
							repeat
								set aqApp to (choose application with prompt "Please find the Acq program" as alias)
								tell application "Finder"
									set appNameIsAQ to name of aqApp is "Acq.app"
									set jResourcesFolderExists to exists folder "Contents:Resources:Java:" of aqApp
								end tell
								if appNameIsAQ and jResourcesFolderExists then
									tell application "Finder" to duplicate my hfile to folder "Contents:Resources:Java:" of aqApp with replacing
									exit repeat

“OSX:Applications:Acq.app:Contents:Resources:Java:” with replacing
→ error number -1728 from folder
“OSX:Applications:Acq.app:Contents:Resources:Java:”
choose application with prompt “Please find the Acq. program” as alias

Nothing wrong with the response except that no java apps appear in the list of apps.
Note: in this case, the Acq app is installed on a different drive. But the script DOES work when the app is in the standard system drive’s application folder.
Is there any way I can fix this?

In regards to my above query:
This is not really a major issue because the main objective of the script works, just that on that small chance someone does have the app situated outside the apps folder. But I guess these days most people use laptops.

What Apple has done with the system I don’t have a clue.

Perhaps there’s two ways to look at this issue. One being an applescript alternative. The other is there a way to make OSX re-recognise Java apps outside of the Applications folder? That’s not exactly an applescript question. :smiley:

I don’t use Gatekeeper as far as I know from what my system settings suggest. I also allow apps downloaded from Anywhere (otherwise they are not executable.) The Java apps do open without issue regardless of which drive they are located.

The “choose application” command lists application known to the system – and only applications within one of the Application folders are known to the system in this context. In other words, it won’t list any apps outside those folders.

Another way is creating an alias in AppleScript, they’re persistent variables between runs like properties so they when not set you scan the whole drive. Afterwards, even when you move the applet to another location, it’s still linked to the original file. It only needs to re-search every time you recompile your code.

try
	theApplet
on error
	display alert "Information:" message "The script will search for application 'Acq.app', this can take up to several minutes depending on the size and performance of the volume."
	set theApplets to paragraphs of (do shell script "find / -name 'Acq.app' &2>/dev/null")
	
	if (count theApplets) = 0 then
		display alert "Error:" message "The application 'Acq.app' cannot be found. Script can't continue."
		return
	end if
	--if there are more than one located, pick the first one found
	set theApplet to alias (POSIX file (item 1 of theApplets))
end try

return theApplet