Bypass "Choose Application" with an variable application path

so, basically,i want to have something run if an application which i do not know the location of exists. I have try/end try surrounding them so if the application doesn’t exist it would just skip over it. I am using a “find” shell script to define the variable that will be the application path, so i cannot choose an application, but it forces me to choose an application.

If the tell block addresses the application by id rather than name or path, you won’t get a choose application dialog.

where can i find the ID? PID and the CFBundleIdentifier in the plist don’t bypass the choose application

Edit: also, the application has other processes that open/close with the same name, but different paths, so depending on which one is open at the time, scripts you try to do will do different things, which is why i am trying to find them using path, but if there is an ID i could use, that would mean that it wouldn’t be a variable application name, unfortunately, both PID and the CFBundleIdentifier make a choose application popup

If you’re dealing with different versions of the same app, you’re out of luck with ids. But something like this:

try
tell application id "com.whatever.wonderware"
-- do something
end tell 
end try

should not result in the choose application prompt at run time if the application can’t be found.

how would you find the ID of a unix application? since theres no info.plist

tell application "System Events"
	unix id of first application process whose frontmost is true
end tell

Is the way to get the id of an OS X app, it is a number that is assigned runtime, for a unix process that is running, we use the unix utility ps, ps -aux is the normal incantation, you can read about ps by entering man ps in a Terminal window.

If there’s no Info.plist it’s not an application as such, and you probably can’t address it using “application” at all. You’ll need to address it via shell scripting and do shell script.

ok, that identifies it, but putting that ID in still has the choose application show up :confused:

It will at compile time, but it shouldn’t at runtime (ie, when you copy the compiled script to a Mac without the app and try to run it).

if the variable is already known , then it compiles fine, so i’m thinking of having another script do the find shell script then give that information to the second script which acutally does the script. the only problem is… i dont actually know how to do that.

It won’t help.
In order to bypass the appearance of the choose application dialog both at compile time and at runtime, you need:

  1. Don’t use tell block (for compile time)
  2. Need to catch a specific error: -1728 (for runtime):

try
	application id "com.whatever.notInstalledApplication"
	set isInstalled to true
on error number -1728
	set isInstalled to false
end try

--> Result: false

With respect, it does. To quote the release notes for 10.5:

I just would like to point out that the code simply refuses to compile with tell block. At least in the Script Editor.

And if it doesn’t compile, how can you use it in a real (large) script? It will simply be useless for automation.

You seem to have taken com.whatever.wonderware and changed it to com.whatever.notInstalledApplication. The discussion was about an app with unknown location, not one that’s not installed.