Connect to vnc server including password, screen sharing

I’m trying to make a simple script to connect to a vnc server using Screen Sharing.app. I can do that much without trouble, but can’t figure out how to include the vnc password in the script. I’m working on the assumption that usernames & passwords are handled the same way for a vnc location as they are for mounting a volume, like this…

tell application “Screen Sharing” to open location “vnc://username:password@vncserver.domain.com”

Our VNC Server setup has no username, just a password (and a username can not be specified). So, naturally I used the following…

open location “vnc://:password@vncserver.domain.com”

…which did not work, but it did launch Screen Sharing.app which prompted me to enter the host (apparently not picking it up from what was specified).

If I forgo the “username:password@” section completely, Screen Sharing.app launches and connects to the VNC Server properly and prompts for the password.

Any idea how to include the blank username and the password in this screen sharing request? Thanks.

Well… I found a way to make this work using System Events to automagically enter the host and password info into the dialogs as they are presented. I don’t like it but it works. There may be too many "try"s in there… ;^)

tell application “Screen Sharing”
activate
try
tell application “System Events”
try
keystroke “vnc://vncserver.domain”
keystroke return
delay 1
keystroke “vncpassword”
keystroke return
end try
end tell
end try
end tell