Use the logIn() and logOut() methods on service objects. Iterate through the services key on the Application('Messages') instance then use the name() method on each service. Note that this will not work well if you have services with the same name. This is a shell script that can log in or out of a service name. Usage: ./thescript 'Service Name' out or in to log in. #!/usr/bin/osascript -l JavaScr