System Preferences Applescripting

This may be a little off topic now… and does use shell scripts, but might help someone?

If you want to your mac/s to autologin temporarily (eg. for deploying a lab) to an existing account, you’ll need to call the following shell scripts in your applescript. For example:

do shell script "shell script command" with administrator privileges 

To enable autologin:

You may also need the kcpassword file (/private/etc/kcpassword) - to get this, enable autologin manually, then make a backup of this file and keep in a separate location, then copy back to its original location as part of your script, eg:

And to disable autologin:

Hey guys,

I got a Kai’s script working great. I’m trying to create an Admin account and can’t figure out how to select the check box “allow user to administer the computer” I know it’s something as simple as setting the value of the Checkbox to 1 (1 for checked, 0 for unchecked). I think I just need some help with the syntax

tell application “System Events”
tell process “System Preferences”
application “System Preferences”
tell sheet 1 of window “Accounts”
set value of text field 1 to “Local Admin”
– Display Name
set value of text field 2 to “LocalAdmin”
– Short Name
set value of text field 3 to “"
– Password
set value of text field 4 to "

– Verify Password
set value of text field 5 to “default local admin pwd”
– Add’s Comment for password hint field
set value of checkbox 1 to 1

        click button "Create Account"
    end tell
end tell

end tell

Any ideas?

Thanks,

Jeff

P.S. Sorry for being a N00B

Model: Tiger 10.4.6
AppleScript: 2.11 (81)
Operating System: Mac OS X (10.4)

I tried "click checkbox “allow user to administer computer”

I also tried set value of checkbox 1 to 1

Never mind… Setting the checkbox value to 1 worked :smiley:

Many thanks for these posts. I had been wrestling with this for some time. Although the tab and down arrow solution works there is something odd about the UI scriptability of the Accounts pane. It just won’t allow you to click on a user with syntax like, say:

tell window “Accounts”
tell list 1
tell group 2
tell static text “username”
set {x, y} to position
set {xs, ys} to size
end tell
click at {x + (xs div 2), y + (ys div 2)}
end tell
end tell
end tell

If anyone knows why, I’d be interested, academically, since I now have my script working.

Thanks again