Import user name and password automatically with AppleScript or Unix Shell I'm trying the Cloud Service tool: Egnyte Drive. But the process "SecurityAgent" will be activated and the administrator's name and password is required the first time when I try to launch Egnyte Drive. I wonder if there is a way to import the administrator's name and password automatically or any way to bypass to activate "SecurityAgent" and launch Egnyte Drive without user name and password. Any suggestions would be appreciated.

Here is what I have tried:

1.

tell application "Egnyte Drive" to activate
    delay 1
        tell application "System Events" to tell process "SecurityAgent"
        set value of text field 2 of scroll area 1 of group 1 of window 1 to "password"
        click button 2 of group 2 of window 1
end tell


The above code is invoked from How to enter password for prompt windows using applescript


do shell script "open -n /Applications/Egnyte\ Drive" user name "USERNAME" password "THEPASSWORD" with administrator privileges
I have installed Egnyte Drive to test your script.

I have found out that you don't need to activate the application at all. Instead "SecurityAgent" is the only process that needs to be addressed:

tell application "System Events" to tell process "SecurityAgent"
    set value of text field 1 of window 1 to "user"
    if exists (text field 2 of window 1) then
        set value of text field 2 of window 1 to "password"
    end if
    click button "OK" of window 1
end tell


Let me know if this works for you as well. I tested it with macOS Sierra 10.12.2 beta.