Adding an App to Login Items??

Sean_Ginn
New Contributor II

I know this has been discussed at length, but I can't figure out how to make this happen. I am trying to get a specific .app to launch when a user logs in, but I can't get the app to show in the list, nor am I able to add the .app to the items list. I appreciate all the help.

9 REPLIES 9

bentoms
Release Candidate Programs Tester

You might be better to look at a launchAgent, I've an example in the post below:

http://macmule.com/2011/09/08/how-to-map-drives-printers-based-on-ad-group-membership-on-osx/

nkalister
Valued Contributor

if you HAVE to use login item (I agree with Ben, use a LaunchAgent if you can) osascript is the best way to do it from a shell script. You'll need to get the logged in user's name and and sudo to that user to execute the command in the script unless you actually want to add this to root's login items :)
here's what I generally use:

sudo su - "$loggedInUser" -c "osascript -e 'tell application "System Events" to make new login item at end with properties {path:"/path/to/yourapp.app", name:"Your App's Name", hidden:false}'"

flip hidden to false or true depending on whether you want it hidden.

slundy
New Contributor III

I created a LaunchAgent for an app we use to manage signatures (Xink).

<?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.emailsignature.Xink</string>
     <key>Program</key>
     <string>/Applications/Xink.app</string>
     <key>RunAtLoad</key>
     <true/>
</dict>
</plist>

I set the permissions to 755 as suggested at macmule.
Placed it in the ~/Library/LaunchAgents folder

It doesn't launch at all.

I've also tried using composer to see what files change when adding it to the login items for the account i'm testing this with and haven't found anything.

Any ideas? Did I miss something?

I did see in macmule's example that he went directly into the app, inside the contents of the app (/Applications/Xink.app/Contents/MacOS/Xink). When I do that, it opens a terminal window that stays open while the app is running (as expected).

We're eventually moving to have it all managed via Office 365 plugin, but for the time being this is how we're using it.

marklamont
Contributor III

this might help you a little script I wrote to make launchagents or daemons for apps or scripts

TK-421
New Contributor

Could someone help me create a LaunchAgent plist? I'll admit that I'm new to managing Macs and this is my first time even hearing of the term. What values am I to enter? I found a sample script online but I'm not sure what I'm looking at:

cat > /Library/LaunchAgents/com.your.application.agent.plist << EOT
<?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.your.application.agent</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/Your Application.app/Contents/MacOS/Your Application</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
EOT

Thanks.

bruth85
New Contributor III

@marklamont Im trying your script to create the LaunchAgent but I am obviously missing something. Every time I try to run it I get * no launcher type selected. Exiting * I have tried typing agent, Agent, LaunchAgent, launchagent, and "agent" all in Parameter 4 but nothing seems to work. What am I doing wrong?

ryan_ball
Valued Contributor

bruth85
New Contributor III

@marklamont and @ryan.ball Thank you both. I figured out after I asked the question that I was being an idiot and instead of putting the parameters in the Policy was putting them in the script under the parameter labels. Guess that is what I get for trying to do something after a vacation and just before a holiday...

kuoirad
New Contributor

@marklamont - your script worked perfectly for me. Made a slight edit to have the plist be us.<mycompany> rather than com.mycorp (for quicker identification), but otherwise used it as is. Many thanks!