Writing Installation Script - Need Help With Login Items

Hey All,

I am not normally an “Apple guy”, so please forgive me if this is an exceedingly simple request. We have over 200 Mac mini OSX (Snow Leopard - 10.6.2) machines going out in a little over a week. They are being deployed into some of our machines in the field, the reason is really irrelevant for the purposes of this question.

With 200 of them going out all at once, and batches of up to 50 at a time scheduled in the near future, scripting the build that takes the machine from an out of the box mac mini to a purpose-specific mac mini is a must. I have 99% of everything done, but I need a way to script the creation of a login item which will fire every time the mini logs in.

I have a script that is mapping an SMB share to a win2k3 server, which works like a charm. I know how to manually get this script to fire upon login, but I need a way to have my installation script configure the mapping script to run on login.

I have tried a few different approaches and I got achingly close with GUI scripting, but I couldn’t get it to click the login script in the dialogue box that asks you to select the item as a login item. Here’s what I have in terms of GUI scripting:

set macPWD to “something”
set winServ to “something”

tell application “System Preferences”
activate
set current pane to pane id “com.apple.preferences.users”
end tell

tell application “System Events”
tell process “System Preferences”
click checkbox “Click the lock to make changes.” of window “Accounts”
delay 2
tell application “System Events” to keystroke macPWD
tell application “System Events” to keystroke return
tell window “Accounts”
tell tab group 1
click radio button “Login Items”
click button 1
end tell
end tell
–with the line below I am trying to select the script in a finder window and in AppleScript editor I get the error “missing value”
–I got the control’s heirarchy with UIBrowser (cool little utility, btw)
click static text 1 of list 1 of scroll area 1 of browser 1 of splitter group 1 of group 1 of sheet 1 of window “Accounts”
end tell
end tell

I have also tried accomplishing this same thing with launchd and a plist file pointing to the applescript which maps the SMB share (saved as an app). I look in the console and I see the following error:

posix_spawn(“/usr/bin/login.app”, …): Permission denied

I’m not sure what permissions it could be missing, since I did the following terminal commands to give permissions to root (which launchd runs as, as I understand it):

chown root /usr/bin/login.app
chgrp wheel /usr/bin/login.app
chmod 755 /usr/bin/login.app
chmod +x /usr/bin/login.app

Again - not a Unix guru, either, but these commands are used earlier in my build process to give root ownership and permissions to some other files. These seem to work like a charm.

I appreciate any help here. It really doesn’t matter to me how I accomplish this last step… the main thing is that it has to be accomplished via a script and not with manual steps.

Hey again - sorry, found this which has done the trick for me!

http://macscripter.net/viewtopic.php?id=35528

Thanks, macscripters!