BlueSense AppleScripts

How to disable Mac OS X session auto login in AppleScript

Disable the Mac OS X automatic login session and prompt for the password next time the computer will start.


script DisableAutomaticLogin
	try
		set my_password to getPassword(KeychainPasswordName)
		set my_username to getUsername()
		do shell script ("/usr/bin/defaults delete /Library/Preferences/com.apple.loginwindow.plist autoLoginUser") user name my_username password my_password with administrator privileges
	on error errString number errorNumber
		log (errString)
	end try
end script