Posted on 04-07-2015 07:49 AM
Hello Nation!
I'm very new to LaunchAgents and wanted to set one up. Currently I'm using a login script that works fine, but I want to move away from login scripts.
What I want to happen: Launch a non-Apple app at login.
I tried a configuration profile but as soon as I typed in .app, it would disappear.
Here's my plist, I'm more than likely doing something wrong and would love if something guided me in the right direction!
~~~~
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ntware.teststation5</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Applications/UniFLOW/MacClient.app</string>
</array>
</dict>
</plist>
~~~~
Solved! Go to Solution.
Posted on 04-07-2015 08:33 AM
@Poseiden951 Although its possible to create Launchd plists by hand, I say why bother when there are apps that will do it for you very easily. Go get yourself a copy of LaunchControl. Its what I use to create Launchd jobs. It makes sure the plist file is valid, has all the correct permissions and makes it easy to simply type in your execute command into a field without needing to know how it should get split up in the programArguments array.
Also, its a nice tool for being able to examine other Launchd jobs as well as reading up on all the available keys that launchd jobs can take. It uses a simple drag and drop interface to add in things like StartInterval or StartCalendarInterval, ThrottleInterval, WatchPaths and tons more.
In the example above, I created a physical Launchd plist using LaunchControl and cat'ed the file afterwards. It gives me the following:
<?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.me.Launcher</string>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>-b</string>
<string>com.jamfsoftware.selfservice</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Hope the above helps.
EDIT: I also just noticed in both of your plist examples above, the hyphen is missing from the flag that open is using. Its either -b, not b, or -g, not g. Without the hyphen before the letter it won't work at all.
Posted on 04-07-2015 07:56 AM
Hi,
Kindly find the changes below. We have to use open command to open an application from command line.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ntware.teststation5</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>-g</string>
<string>/Applications/UniFLOW/MacClient.app</string>
</array>
</dict>
</plist>
Thanks & Regards,
Karthikeyan
Posted on 04-07-2015 07:59 AM
Hi. I may be able to help.
So, first thing is, I might consider using the applications bundle identifier instead of an actual path to the app. only because if the application gets moved at all, your LaunchAgent won't work anymore. Using a Bundle Identifier means the system can locate the application wherever it might be (as long as its not buried too deeply in the OS) and launch it.
Second, in most cases, you need to either use the open command, or use a path all the way to the app bundle's executable inside the "MacOS" directory to launch it.
Here's an example of how I would have the Self Service application open at login using a LaunchAgent. This uses the open command the app's BundleID:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mysslauncher</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>-b</string>
<string>com.jamfsoftware.selfservice</string>
</array>
</dict>
</plist>
As you can see, the syntax is in the form of:open -b <bundleidentifier>
To get the app's Bundle Identifier, you can use defaults:
defaults read /Applications/UniFLOW/MacClient.app/Contents/Info CFBundleIdentifier
Give that a try and see if it works for you.
Posted on 04-07-2015 08:24 AM
Thanks for the response @karthikeyan.mac and @mm2270
So, I've tried:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.uniflow.login</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>b</string>
<string>com.NT-ware.pkg.uniflowMacClientWithUniversalDriver.macclient</string>
</array>
</dict>
</plist>
and
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.uniflow.login</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>b</string>
<string>/Applications/UniFLOW/MacClient.app</string>
</array>
</dict>
</plist>
I save the files as com.blahblah.login.plist in /Library/LaunchAgents
They sadly don't work. I looked at the logs in Console and it said:
"4/7/15 10:20:08.277 AM com.apple.xpc.launchd[1]: (com.apple.xpc.launchd.user.1094173662.100194.Aqua) Could not parse plist: path = /Library/LaunchAgents/com.ntware.login.plist, error = 109: Invalid property list"
and
"4/7/15 10:20:08.277 AM com.apple.xpc.launchd[1]: (com.apple.xpc.launchd.user.1094173662.100194.Aqua) Failed to bootstrap path: path = /Library/LaunchAgents/com.ntware.login.plist, error = 109: Invalid property list"
Posted on 04-07-2015 08:33 AM
@Poseiden951 Although its possible to create Launchd plists by hand, I say why bother when there are apps that will do it for you very easily. Go get yourself a copy of LaunchControl. Its what I use to create Launchd jobs. It makes sure the plist file is valid, has all the correct permissions and makes it easy to simply type in your execute command into a field without needing to know how it should get split up in the programArguments array.
Also, its a nice tool for being able to examine other Launchd jobs as well as reading up on all the available keys that launchd jobs can take. It uses a simple drag and drop interface to add in things like StartInterval or StartCalendarInterval, ThrottleInterval, WatchPaths and tons more.
In the example above, I created a physical Launchd plist using LaunchControl and cat'ed the file afterwards. It gives me the following:
<?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.me.Launcher</string>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>-b</string>
<string>com.jamfsoftware.selfservice</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Hope the above helps.
EDIT: I also just noticed in both of your plist examples above, the hyphen is missing from the flag that open is using. Its either -b, not b, or -g, not g. Without the hyphen before the letter it won't work at all.
Posted on 04-07-2015 08:06 PM
Played around with LaunchControl and it's works on my personal laptop. I'll have to test it out at work and see if it works!
@mm2270 Thanks for all your help, I'll probably purchase it even though it isn't required.