i’m making a little script to be run on a group of machines, in which there are several programs which can be launched from the script. not all of the programs are present on all of the machines, however.
if the script is run on a machine missing one or more programs, it prompts the user to find the program on the disk, which is not the behavior i want. if the script can’t find the program, the program doesn’t exist! how does one prevent applescript from prompting users to locate these apps…?
Here’s a solution using the file ID of applications (all credits to Rob)
try
tell application "Finder" to set theApp to application file id "TTXT" as string
on error -- the app is not installed...
display dialog ¬
"The application was not found on your system." buttons {"Cancel"} default button 1
return -- quit script
end try
Note: The file ID is case sensitive and may contain spaces. The proper case and spaces are required for accurate results. For instance, the example above will likely say that the application was not found, but if the file id is changed to “ttxt”, it should find the TextEdit application. Jon has provided a script (above) to find the correct ID.
Ah, I love tautology. To get an application’s path as a string you need the creator code and to get that you need the application’s path as a string. In other words:
Now again, this is just for the prep work of your script, after you have the creator code, all you’ll use in a script for distribution is: