0

I want to mount a dmg as nonremovable image using AppleScript as described here. The difference is that my dmg is encrypted.

When I execute

do shell script "hdiutil attach /path/to/my.dmg -notremovable" with administrator privilege

root password is asked and then nothing happens (I'd expect a prompt for dmg's password) and the script runs until closed in Activity Monitor.

If the script is executed without "with administrator privilege" then the dmg's password is asked right before I get "hdiutil: attach failed - Permission denied" error.

The console version works fine:

sudo hdiutil attach /path/to/my.dmg -notremovable

Why AppleScript does not ask for the dmg's password? Does it "hide" the second prompt for some reason?

0

Still don't know how to do in properly, but here is the workaround:

display dialog "Password for the image" default answer "" with hidden answer
set the pass to the text returned of the result

do shell script "echo -n " & pass & " | hdiutil attach /path/to.dmg -notremovable -stdinpass" with administrator privileges
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.