Helper applets not being identified on new machine


#1

I have an applet which I code sign and export in read only format for other people to use at work.

The applet’s resources bundle contains two helper applets.

My main applet uses the helper applets by sending them commands like tell application app_name to run; or tell application app_name to doThisHandler; etc.

It seems that at least sometimes when the main applet is run for the first time on a new machine, it asks the user to choose/locate the helper applets. And as the helper applets are in my applet’s resources bundle and the choose app dialog only displays the applications folder, the user isn’t able to view and select the helper applets.

The current work around is to view package contents in the Finder and then double click once on each of the helper applets. After that it works fine.

is there a more elegant way I can ensure a new machine knows where the helper applets are?

One possible solution I’ve thought of is to simply copy the helper applets from my applets bundle into the applications folder on first launch, but I’d prefer not to have to pollute the users applications folder with helper applets that may be confusing to the user.


(Shane Stanley) #2

You could try using tell application path_to_helper rather than relying on the name only.


#3

Thanks, Shane. would it work like this do you think?

tell application (path to resource helper_app_name in bundle (path to me) in directory "Helper Apps") to run

I sometimes find the path to resource command a bit flaky when running in SD or SE, and sometimes as an apparent workaround have to store the resource in a variable first and then reference it that way.


(Shane Stanley) #4

This. The path to command is part of Standard Additions, so it’s preferable to keep its use outside app tell blocks.


#5

If I do:

path to resource helper_app_name in bundle (path to me) in directory "Helper Apps"

then I’m getting an error because the app can’t be found in «script my_script_name».

I’m guessing if I do:

path to resource helper_app_name in bundle (path to current application) in directory "Helper Apps"

it will work when I run it from Finder, but not when I run it from SD.

Is there a better way to do it?


#6

The error I’m getting is along these lines:

Can’t get application (alias “Macintosh HD:Users:…:APP_NAME.app:Contents:Resources:Helper Apps:HELPER_APP_NAME.app:”) of «script SCRIPT_NAME».


(Shane Stanley) #7

Actually, it’s probably fine there.

You need to use the path, not an alias.


#8

Ahh, yes, thanks – I need to tell app path_to-_app as text not tell app alias_of_app. Thanks, Shane – everything is now working on my main machine. I’ll now see if I can test it; hopefully simply creating a new user account will simulate the issue.