Launching 2 programs with the same name.

So with the pretense that this might be a dumb question, I have to ask it anyway.

I have two different programs in two different folders under my applications. The company that created them both had the genius idea to name the actual applications with the exact same name. Granted they have similar interfaces but that is besides the point.

I have the following script that mounts a hard drive, launches one of the applications, and continues to check until the app is no longer running before unmounting the hard drive. It has been working great until this issue has come up. I tried to simply renaming the other program with a similar name and run the same script, but there are other files that are searching for the original name in order for it to run. Since I don’t know which ones are actually looking for it, I have to leave the name the same.

Is there any way to direct the script to launch and app from a predetermined folder instead launching based on it’s name like it is below?

set sfiles to "afp://admin:pass@servername/harddrive"
tell application "Finder"
	activate
	mount volume sfiles
end tell

delay 5

tell application "[i]appname[/i]" to activate

tell application "System Events"
	set isRunning to ((application processes whose (name is equal to "[i]appname[/i].app")) count)
end tell
repeat until isRunning is 0
	tell application "System Events"
		set isRunning to ((application processes whose (name is equal to "[i]appname[/i].app")) count)
		delay 4
	end tell
	if isRunning is less than 1 then
		set sfiles to "hardrive"
		tell application "Finder"
			activate
			eject sfiles
		end tell
	end if
end repeat

If you know the full path to the application, you could do something with the application file to make sure the right app is active:

property appPath : alias "Macintosh HD:System:Library:CoreServices:Finder.app"
property appName : "Finder"

appIsActive(appName, appPath)

on appIsActive(aName, anAlias)
	tell application "System Events"
		set allProcs to every application process whose name is appName
		
		repeat with i in allProcs
			if (application file of i) as alias is appPath then return true
		end repeat
	end tell
	return false
end appIsActive

You could also activate the application by referencing to it via a path:

property appPath : alias "Macintosh HD:System:Library:CoreServices:Finder.app"

tell application (POSIX path of appPath) to activate

Hope it works,
ief2

The second option works great. However I have two machines I am working on. One is an powermac g5 Intel running 10.5 (which this script works fine with, The other is a PowerPC Mac G5 running 10.4. When I run the script on that machine, it says it cannot find the Application location, and prompts me to find it manually. I thought I have ran into this issue before when crossing into the intel world, but I’m not quite sure. I thought the issue has to do with using forward slashes instead or colons when creating your file path, but I can’t seem to get it adjusted right. Such as:

property appPath : alias "Macintosh HD:System:Library:CoreServices:Finder.app"

tell application (POSIX path of appPath) to activate

or

property appPath : alias "Macintosh HD/System/Library/CoreServices/Finder.app"

tell application (POSIX path of appPath) to activate

what’s about

do shell script "open -a /Applications/TextEdit.app"

I don’t suppose simply renaming one of the apps to a unique name would solve it easier?

I had a similar problem”two versions of FileMaker Pro on the same machine. An older version used for corporate software and a 2-version-newer version for software I wrote. I ran into the same issue you did and found it most reliable to just rename one of the apps. In my case I renamed the newer version to “FileMaker Pro 7” and the older one was left alone.

When searching to launch an app, AppleScript seems to have no problems with literal Finder names to make such differentiations. And most apps themselves don’t seem to care much about their own name, in my experience.

Of course, I only had to do that on a half-dozen machines”not sure what your situation is.

As always. Works perfectly. Thanks Stefan.

As always. Works perfectly. Thanks Stefan.