Trouble with global login items

Discussion in 'Mac Programming' started by Kadrin88, Sep 8, 2010.

  1. Kadrin88 macrumors newbie

    Sep 1, 2010
    Morning all,

    I'm working on an issue with global login items. I've set one up to run a script that I wrote. The script is:

    defaults write DSDontWriteNetworkStores true 
    The script has read/execute permissions as does the encapsulating folder. I'm using the latest version of OS X (not at mac right now so I can't recall what it is). Here is the site from which I found out how to assign a global login item: . I ran the command:
    defaults write /Library/Preferences/loginwindow AutoLaunchedApplicationDictionary -array-add '{ "Path" = "/path/to/script"; "Hide" = "0"; }'
    with /path/to/script/ being it's location.

    After I rebooted and logged in, the login item didn't work but it did open the script up in xCode. Is there something I did wrong to have it open the script up instead of running it? I thought it might have ran the script and opened it, but after doing a defaults read, it returned with error.
  2. Kadrin88 thread starter macrumors newbie

    Sep 1, 2010
    Any ideas? I'm relatively new to the Mac OS X platform. Let me know if there is any more information needed.
  3. chown33 macrumors 604

    Aug 9, 2009
    on the Western Slopes, with E. A. Poe
    Don't bump threads. It's against forum rules.

    It's only been 4 hours since you posted. Be patient. People who might answer your question may be in a very different time zone than you.

    AutoLaunchedApplicationDictionary is intended for bundled applications.
    It isn't intended for shell scripts.

    Notice there is a heading for "Login Items" and a separate heading for "Loginwindow Scripts".

    I don't know why you want to go through the complexity of a global script to set a flag, when you can just set a global flag once and have every user see it.

    Command to set global flag:
    defaults write /Library/Preferences/ DSDontWriteNetworkStores 1
    Run it once as an admin user. You may have to logout and login again for the change to take effect. You may also have to delete any per-user override:
    defaults delete DSDontWriteNetworkStores

    I assume that setting a flag globally is your actual goal, and that writing a global login script to do it was simply your attempted solution. If this script was only an example, however, and your real goal is to learn how to write and deploy any number of different login scripts, then please clarify exactly what your goal is.

Share This Page