2

I want to launch myapp.app during login time and it should work for all users.

I tried with osascript which launch only for a user who run that command .

/usr/bin/osascript -e "tell application \"System Events\" to make a new login item with properties {path : "Path/myapp.app" hidden:false name:"myapp"} at end "

I ran this log-in as a guser .So it launches during login of only guser .

And even i tried with sudo defaults write /Library/Preferences/loginwindow AutoLaunchedApplicationDirectory -array-add '{ "Path" ="path1" ; "Hide"="0";}'

When path1=myapp.app it didnt worked When path1=myapp.app/Contents/MacOS/myapp it is launching for all users but even a terminal window is launching along with the application .

I have a shell script from that i have to some command that launches cocoa app for all users login time. Please help .

user12345
  • 425
  • 1
  • 3
  • 14
  • Duplicates http://stackoverflow.com/questions/5449135/how-can-a-cocoa-application-add-itself-as-a-global-login-item – paulmelnikow Mar 12 '13 at 18:45
  • For information about why `sudo defaults write` doesn't work, see http://stackoverflow.com/questions/9483959/osx-10-8-loginitems – paulmelnikow Mar 12 '13 at 18:46

1 Answers1

0

You can use LSSharedFileList API.
Take a look at How can a Cocoa application add itself as a global login item? and Register as Login Item with Cocoa?

Take a look at Technical Note TN2083(Global Login Item)

A global login item is a login item that is launched when any user logs in. Installing a global login item is roughly equivalent to installing that login item for all users on the system: every time a user logs in, loginwindow launches that user's login items and all global login items.

Community
  • 1
  • 1
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144