Skip navigation
This discussion is archived

Encrypted disk image mounting

628 Views 2 Replies Latest reply: Oct 3, 2006 3:24 PM by Khadrelt RSS
Khadrelt Calculating status...
Currently Being Moderated
Oct 3, 2006 11:24 AM
I'm trying to find a way to make an AppleScript that will mount an encrypted disk image and enter the password for it automatically. I can make it open all right, but I can't figure out how to make it enter the password (the 'with password' command doesn't seem to work, I'm assuming it only works on remote volumes?).

Any help would be appreciated.
1.25 gHz Mini, Mac OS X (10.4.6)
  • Steve Herman1 Level 4 Level 4 (2,545 points)
    Currently Being Moderated
    Oct 3, 2006 12:34 PM (in response to Khadrelt)
    Something like this should work:
    set myResult to display dialog "Enter password:" default answer "" with hidden answer
    set thePW to text returned of myResult

    set cmd to "echo -n \"" & thePW & "\" | hdiutil attach /path/to/encrypted/disk/image.dmg -stdinpass"
    do shell script cmd
    There are some security concerns with passing a command string to "do shell script" that contains your password. If other users log on to your machine they could see your password if they happened to be watching the process list at just the right time.

    20" iMac G5, Mac OS X (10.4.7)


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.