You are not logged in.
hello,
this grew out of an idea i had after reading this post:
http://bbs.applescript.net/viewtopic.php?id=14141
it will give you a list of 'users' and let you pick the one you want to have 'autoLogin' when you start the computer. hopefully this will be useful to someone:
Applescript:
set getUsers to (do shell script "/usr/bin/nireport / /users name uid | grep \"5[0-9][0-9]\"")
set howMany to number of paragraphs in getUsers
set theUsers to {missing value}
set i to 1
repeat while i ≤ howMany
if i = 1 then
set theUsers to word 1 of paragraph i of getUsers as list
else
set theUsers to (theUsers & word 1 of paragraph i of getUsers)
end if
set i to (i + 1)
end repeat
set autoLoginUser to (choose from list theUsers)
if autoLoginUser is not false then
do shell script "/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser " & autoLoginUser with administrator privileges
display dialog "User " & autoLoginUser & " is now the default Auto Login."
end if
Offline
Slick Waltr. So slick that I've moved it to Code Exchange
Offline
hello,
i found a bug in the code for this. the new code also adds the UID of the autoLoginUser:
Applescript:
set getUsers to (do shell script "/usr/bin/nireport / /users name uid | grep \"5[0-9][0-9]\"")
set howMany to number of paragraphs in getUsers
set theUsers to {missing value}
set i to 1
repeat while i ≤ howMany
if i = 1 then
set theUsers to word 1 of paragraph i of getUsers as list
else
set theUsers to (theUsers & word 1 of paragraph i of getUsers)
end if
set i to (i + 1)
end repeat
set autoLoginUser to (choose from list theUsers)
if autoLoginUser is not false then
set userInf to (do shell script "/usr/bin/nireport / /users name uid | grep " & autoLoginUser)
set userNum to word 2 of userInf
do shell script "/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser " & autoLoginUser with administrator privileges
do shell script "/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUserUID " & userNum with administrator privileges
display dialog "User " & autoLoginUser & " is now the default Auto Login."
end if
it seems to work better. as always, comments welcome.
Offline
Thanks guys, I have used your advice to create a couple of scripts that enable & disable autologin, to use when auto-deploying a mac lab.
To enable autologin, I created an applescript, which calls the following shell scripts:
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser yourusername
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUID yourUIDnumber
I found that I also needed the kcpassword file (/private/etc/kcpassword) - to get this, enable autologin manually in system preferences, 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:
cp /Path/To/Backup/kcpassword /private/etc/kcpassword
And to disable autologin (in our lab, this is part of a shell script that gets run as a loginhook):
/usr/bin/defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
srm /private/etc/kcpassword
Hope this helps someone?
Offline