I’m running MacBook with macOS Sierra version 10.12.5. I would like to know the commandline setting to change to UNCHECK the “Disable Automatic login” under “Security & Privacy”. I can do this by using the UI. However since I have to redo this repeatedly, I’m trying to do this using a script.
Edit: This is a corporate owned MacBook. If I want to do this, I have to do it everytime I reboot because this setting gets reset on reboot. This may also be the reason why my attempt mentioned below did not work. However, I can do this manually, so the settings are not so restrictive, so I'm guessing I might be able to do this on the commandline.
I tried the process mentioned in Editing System Preferences via Terminal – but the only difference I get is in com.apple.loginwindow.plist
where it differs in the LoginwindowText
. I don’t think this is the setting.
Can someone tell me which is the commandline setting for unchecking this box?
Edit: In response to Mark's suggestion, I tried the following:
try
set thePW to "mypassword"
tell application "System Events"
tell application "System Preferences"
activate
end tell
tell process "System Preferences"
activate
delay 1
click menu item "Security & Privacy" of menu "View" of menu bar 1
delay 3
if title of button 1 of window 1 is "Click the lock to make changes." then
click button 1 of window 1
delay 2
keystroke thePW
keystroke return
end if
get properties
--set properties to {automatic login:true}
end tell
end tell
on error errMsg
display dialog errMsg
end try
This code starts “Security & Privacy” and puts in my password to login. Unfortunately, the get properties
does not show me anything about automatic login
. I get the following result:
{has scripting terminology:true, bundle
identifier:"com.apple.systempreferences", file:alias "Macintosh
HD:Applications:System Preferences.app:" of application "System
Events", creator type:"sprf", subrole:missing value, entire
contents:{}, selected:missing value, application file:alias "Macintosh
HD:Applications:System Preferences.app:" of application "System
Events", orientation:missing value, role:"AXApplication", accepts high
level events:true, file type:"APPL", value:missing value,
position:missing value, id:28015286, displayed name:"System
Preferences", name:"System Preferences", class:application process,
background only:false, frontmost:true, size:missing value,
visible:true, Classic:false, partition space used:0, role
description:"application", maximum value:missing value,
architecture:"x86_64", short name:"System Preferences",
focused:missing value, minimum value:missing value, help:missing
value, title:"System Preferences", accepts remote events:false, total
partition size:0, description:"application", accessibility
description:missing value, enabled:missing value, unix id:57066}
In the above mentioned code I have commented out the set properties to {automatic login:true}
line. If I enable it I get the error:
error "System Events got an error: Can't make {automatic login: true} into type of properties of process." number -1700 from
{automatic login: true}
I'd be grateful for any help.
Best Answer
I do not recommend doing this, as it increases security risk, but to answer the question, see below.
I do not have the same macOS version so was not able to test, but you can try creating an AppleScript to do this for you.
Create AppleScript to Disable automatic logic and save to ~/bin/disable-automatic-login.osa
Make sure to enable execution
chmod +x ~/bin/disable-automatic-login.osa
Add ~/bin to path and run
$ disable-automatic-login.osa
to disable the automatic login.Troubleshooting
The documentation is out of date, so the properties may be incorrect, but the idea is the same. You can discover the properties in the Script Editor.app by running the following in the app:
and change the script with the correct properties.
Extra: Automatic Launch at login with launchd
See http://developernotes.com/archive/2011/04/06/169.aspx