add Login Item on a user level

roiegat
Contributor III

I have a application called DriveConnect.app that maps the users network drives. I'd like to have it run at login since WIFI would be connected. I would like to add the application as a login item to each user after installing this app on their machine. I tried adding it to the startupitems folder but the user gets a security error on reboot. So I'm back to trying to add it to login items.

I looked up in JAMF nation but only found one example using the growlhepler but trying to copy it didn't work. So I'd like some help in creating a MSX for this app.

The location of the applicaiton is /applications/driveconnect.app

Thanks.

4 REPLIES 4

talkingmoose
Moderator
Moderator

This is perfect for launchd.

I have a gist on github.com with instructions:
https://gist.github.com/1215744

You'd replace my domain with yours and specify whatever application you wish.

bentoms
Release Candidate Programs Tester

I needed to do the same, so wrote a launchagent. Details of the whole process here: http://macmule.com/2011/09/08/how-to-map-drives-printers-based-on-ad-group-membership-on-osx/

Part that will be of use;

[quoteLaunchAgent

All the above will only work when run as the user you wish to mount the drives & printers as,  for this I created a LaunchAgent.

As this will allow the app to run at every login & as the  user logging in.

To create the LaunchAgent, copy the below. Replace APPLICATIONNAME with the name of your AppleScript application & save as com.APPLICATIONNAME.plist in /Library/LaunchAgents/ with 755 permissions. NOTE: Replace [ with .

[?xml version="1.0" encoding="UTF-8"?]
[!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"]
[plist version="1.0"]
[dict]
[key]Label[/key]
[string]com.pentland.drivesandprinters[/string]
[key]Program[/key]
[string]/Applications/Pentland Drives And Printers.app/Contents/MacOS/applet[/string]
[key]RunAtLoad[/key]
[true/]
[/dict]
[/plist]

You should be able to test this now, by logging out then in on a mac that has the app & this LaunchAgent, but you may run into an issue or 2. The below will help with that.
]
{/quote}

stutz
Contributor

We have an in-house application we run at users startup. You can edit the "loginwindow.plist" file (located in the ~/Library/Preferences folder). Example is detailed below of what entries to add to the plist. Now just create a configuration profile (I used this) or upload the plist to the managed preferences in the JSS and when the user signs in it will run that program at startup.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict> <key>AutoLaunchedApplicationDictionary-managed</key> <array> <dict> <key>Hide</key> <false/> <key>Path</key> <string>/Applications/Utilities/AppName.app</string> </dict>
</plist>

bentoms
Release Candidate Programs Tester

Honestly, a launchAgent is the way to go.