Replicate Open Alias File in Applescript - Encrypted Disk Image


I have an alias file on my desktop which points to an application on an encrypted disk image.

When I click on the alias file in the Finder, I am prompted to enter the password for the disk image. As soon as the password is correctly entered, the disk image mounts and the application runs. No worries.

But how do I have applescript replicate this behaviour?

I have this script:

tell application "Finder"
	open alias file "HD:Applications:AppAlias"
end tell

The script runs, but does nothing. No prompt.

What am I missing here?


That path (if it is at all correct) does not point to an item on your desktop, but to something in the Applications folder.
Select the alias, then run this scriptlet, and look in the result pane (bottom of Editor window) for the actual path of your alias:

tell application "Finder"
	set this to item 1 of (get selection) as alias
end tell

Stick that in your script, and remove “alias file”:

tell application "Finder"
	open "path:to:alias:on:your:desktop"
end tell


I had moved the alias to the Applications folder so the path was correct.

I tried :

tell application "Finder"
   open "HD:Applications:AppAlias"
end tell

No luck. Script runs but no result. It does not resolve the alias. No prompt for password.

Mmm. It works for me, with an alias to a random app in /Applications.
It could be some problem with presenting the password dialog, no ideas there. Which OS version are you running?

I am running Snow Leopard 10.6.8

Did you have the alias file linked to an app on an encrypted disk image (with the disk image unmounted)?

Judging from your post, I am guessing not.

In that scenario, if you click on the alias file, the Finder resolves the alias, prompts for the password, mounts the disk image and then opens the app (all automagically).

But “opening” the aiias file via applescript apparently does not do the same thing as double clicking it in Finder.


Well, I tried it with an encrypted image, and yes, script runs, but nothing happens (10.6.8, me too).
I noticed a dialog “resolving alias” after double clicking the alias, but that does not happen with the script. Not a single event gets sent! Mystery indeed!

I have “resolved” the issue by using Quicksilver. When the alias file is opened using Quicksilver, it behaves in the same was as when double clicked in Finder.

If someone has the applescript answer though, I would be curious to learn!


Have you tried

tell application "Finder"
	open (original item of alias file  "HD:Applications:AppAlias")
end tell

Hi Stefan

Tried that. It throws an error:

Weird! It cannot resolve the alias. While FInder on its own can.

AppleScript is becoming senile… :mad:

is the original file on a shared volume?


The original file on the encrypted disk image. And the disk image is located on the startup disk. I am working off a MacBook Pro with a single partition.

Hope that helps

As you’re using AppleScript anyway, mount the image with AppleScript explicitly and open the file

Yes, I have a script that does that. However, it is of course more involved (and therefore prone to error).