PDA

View Full Version : Trouble with global login items




Kadrin88
Sep 8, 2010, 09:04 AM
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 com.apple.desktopservices 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: http://mattdanger.net/tag/login-items/ . 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 com.apple.desktopservices.DSDontWriteNetworkStores, it returned with error.



Kadrin88
Sep 8, 2010, 01:23 PM
Any ideas? I'm relatively new to the Mac OS X platform. Let me know if there is any more information needed.

chown33
Sep 8, 2010, 01:59 PM
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.
http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Articles/CustomLogin.html

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/com.apple.desktopservices 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 com.apple.desktopservices 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.