1

I have an automation (screenshots of it here: https://www.icloud.com/iclouddrive/0bB-1AiIWdJc1jmkfdjRbsAVA#Launch_Plex_Media_Automation_ )saved as an app in Automator with the following AppleScripts to mount an encrypted DMG file, enter the password in security agent pop up and click OK. macOS is Catalina.

It worked wonderfully for two years. Then it stopped working. After several attempts to fix the script, I went into Time Machine and retrieved the script from a time I knew it was working. It worked great for a bit but now it works a few times then stops entering the password. If I run just the script from Script Editor, it works great. Same if run from Automator. It will continue working in the automation until I shut my MBP down, then it's back to waiting for me to manually enter the password again. The automation has full disk access.

Suggestions to fix this please?

tell application "MountDMG"
    activate
end tell

delay 5

tell application "System Events"
    set value of text field 1 of window 1 of process "SecurityAgent" to "Password"
    click button 2 of window 1 of process "SecurityAgent"
    --> button "OK" of window 1 of application process "SecurityAgent"
end tell
4
  • Why not just save the password in your keychain? Commented Jun 25, 2021 at 23:24
  • Want to avoid that. DMG is my eyes only Commented Jun 25, 2021 at 23:35
  • 2
    RE: "Want to avoid that. DMG is my eyes only" -- Then I hope you are not saving the "Password" in the script, as even set as a Run-only app the password is in plain text. Commented Jun 25, 2021 at 23:44
  • Do you need to use MountDMG? If not, you should be able to use something like printf '%s\0' 'Password' | hdiutil attach -stdinpass /path/to/image.dmg Commented Nov 28, 2021 at 2:37

1 Answer 1

0

I have a sneaky suspicion that this small adjustment may solve your problem.

tell application "MountDMG"
    activate
end tell

delay 5

tell application "System Events"
    repeat until exists of text field 1 of window 1 of process "SecurityAgent"
        delay 0.1
    end repeat
    set value of text field 1 of window 1 of process "SecurityAgent" to "Password"
    delay 0.1
    click button 2 of window 1 of process "SecurityAgent"
end tell
5
  • With the delay 5 already in the script I be surprised if that repeat loop is even necessary, but lets see if it makes a difference for him. Commented Jun 26, 2021 at 0:42
  • Thx. I’ll try it. Commented Jun 26, 2021 at 5:20
  • no change with the new script. third time this automation has stopped working after and extended period of time. I was getting a message that the app wasn't allowed assistive access, event though permissions were given. I added ServicesUIAgent, to accessibility as well. this stopped the message but when I restart the MBP it will no longer type in the password. If I type it in manually, dismount the DMG, and run the automation again, it works great. I will screen shot the entire automation and include the link here. Perhaps I have something else that is not set correctly. Commented Jun 30, 2021 at 8:33
  • I updated to a simpler script. tell application “LaunchDmg” activate end tell delay 5 tell application "System Events" set value of text field 1 of window 1 of process "SecurityAgent" to “Password” click button 2 of window 1 of process "SecurityAgent" --> button "OK" of window 1 of application process "SecurityAgent" end tell I get this message, error "System Events got an error: Can’t set process \"SecurityAgent\" to \”Password\”.” number -10006 from process "SecurityAgent" despite the fact that it did open dmg. but the message stops the next action completing Commented Jul 9, 2021 at 5:28
  • After several attempts, deleting the app from assistive access and re-entering it then restarting my MBP seem to fix the problem for now. Commented Jul 12, 2021 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .