Ok, so we have:
set the_app to "/Applications/Safari.app/"
tell application "System Events" to make login item at end with properties {path:the_app, hidden:false}
How would I change this to add the login item to a list of users? Something like…
set user_list to {"user1", "user2", "user3"}
set the_app to "/Applications/Safari.app/"
repeat with i in userList
tell application "System Events" to make login item at end with properties {path:the_app, hidden:false} for user i
end repeat
Thanks,
-Rob
I figured it out using the “defaults” command.
Could you please post back to submit your solution?
do shell script "sudo defaults write /Path/to/user/Library/Preferences/loginwindow '{
AutoLaunchedApplicationDictionary = (
{
Hide = 0;
Path = \"/Path/to/loginitem.app\";
}
);
BuildVersionStampAsNumber = 17371360;
BuildVersionStampAsString = 8J135;
SystemVersionStampAsNumber = 168036096;
SystemVersionStampAsString = \"10.4.7\";
}'"
In my case, we were only adding 1 application to each of the users, which was the script to mount their corresponding sharepoint. So, I just completely wrote over their loginwindow plist with this.
Also, you’ll need to do a: chown user:group /Path/to/user/Library/Preferences/loginwindow.plist
after editing it with the defaults program, as it changes the owner of the file to whomever was running the utility at the time.