Mounting CD-Rom then executing a application off it - fails

Hi everyone,

First time poster, long time reader. I was wondering if someone could tell me what wrong with this code:


mount volume “afp://10.0.100.21/CdromX”

try
close window “CdromX”
end try
delay 10
tell application “CdromXApp” to activiate

Basically, I need to make a script that will open a CDROM, and execute a program on it. Unfortunately, when I try my script it always asks for the application everytime unless the Cdrom is mounted. And to add to the confusion, if you mount the CDROM once, the script will work!!! But if you restart the computer, it forgets it was on the CDROM.

I’ve been struggling for weeks on this… any ideas?

thanks in advance,
Dave

There are several ways of dealing with this problem which stems from the way AppleScript targets applications.

The crux of the problem is that the application isn’t always around. You can solve this by specifying the full pathname of the app to open.

The second issue is in compiling the application, since AppleScript will want the application available when you compile the script. You can overcome this by using a variable to store the application name, so something like this should work:

set theApp to "CDRomX:CDRomX.app"
tell application theApp to activate

The alternative solution is to not target the application, but to have the Finder open the app:

tell application "Finder"
   open "CDRom:CDRomX.app"