Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

An AppleScript workaround for login items bug System
There are some reported instances, as well as an Apple KnowledgeBase article, concerning OS X hanging when multiple login items are specified. David Nelson, the author of the "Is Classic running?" AppleScript mentioned here recently has written a script which addresses this issue.

David explains it much better than I could, so here's what he said about the script:
This script is a workaround for the issue of applications hanging or causing the system to hang when multiple applications are specified as login items in System Preferences > Login panel.

The workaround is accomplished by specifying the script as the sole login item. When the script runs it opens any aliases it finds in a "Login Items" folder of its own, which resides in the same folder as the script. The script waits five seconds between opening each alias, which avoids the bug that is causing problems when multiple apps are launched at once. If you want an application to be hidden after it is launched, simply do a Get Info on its alias in the script's "Login Items" folder and enter the word "hide" in the comment field.
A simple, effective solution to the problem, at least until its officially addressed by Apple.

Read the rest of the article for David's script...

property pPathToLoginItemsFolder : "" -- The script will set this value.
set loginItemsList to {} -- The script will set this value.
set interLaunchDelay to 5 -- Seconds between launching applications. Feel free to fiddle with this one.

tell application "Finder"
set pPathToLoginItemsFolder to ((container of (path to me) as alias) as text) & "Login Items:"
set loginItemsList to every item of folder pPathToLoginItemsFolder whose kind is "Alias"
repeat with i in loginItemsList
open i
delay interLaunchDelay
if (comment of i is "hide") then
set visible of process ((displayed name of i) as text) to false
end if
end repeat
end tell
As explained above, just save the script into a folder, create a new Login Items folder in that same folder, and then place aliases to your startup apps in the Login Items folder. Add the script as the only app to be run at login, and you should have a viable multiple login items launch solution.
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[11,384 views]  

An AppleScript workaround for login items bug | 10 comments | Create New Account
Click here to return to the 'An AppleScript workaround for login items bug' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Re: Login script
Authored by: chrispar on Mon, Dec 10 2001 at 7:52AM PST
Great script! But, how do I make an alias of iTunesHelper when I can't find it?


[ Reply to This | # ]
Re: Login script
Authored by: Yertman on Mon, Dec 10 2001 at 5:35PM PST
Hello,

The iTunesHelper app is located inside of the iTunes.app package, right here to be specific: iTunes.app/Contents/Resources/iTunesHelper.app To access the contents of a package, right click on the package and select "View package contents" from the contextual menu.

Unfortunately, it is not quite a normal application as it does not open if you double click on it.

You can however make iTunesHelper launch with AppleScript:

tell application "iTunesHelper"
activate
end tell

My login items script only opens alias files, so if you save this script directly in the login items folder it will be ignored. Instead save the scipt someplace else then make an alias to it and put that in the login items folder. Another option would be to paste this little scrap of script right into the login items script.


HTH
David Nelson (AKA Yertman)



[ Reply to This | # ]
Re: Login script
Authored by: chrispar on Wed, Dec 12 2001 at 5:12AM PST
Thanks - that worked!


[ Reply to This | # ]
Great Script - even sped up login
Authored by: saint.duo on Mon, Dec 10 2001 at 10:57AM PST
This script has solved one of my biggest issues on my beige G3. Typically, if I have 3 or more items in my login items, there is a 70% chance that the computer will hang on login. Well, having added Microsoft Office last night, that made three (MagicMenu, MouseWorks Background, and the Microsoft Database Daemon).

The hard disk activity when I login has dropped tremendously after using this script instead of putting those things in my login items, and the time has dropped, as well.

One thing to note, is that the Microsoft Database Daemon put itself back into the login items upon logout/login. If anyone knows how to keep it from doing this, I would love to know.

[ Reply to This | # ]
Can't get App to hide
Authored by: evlded on Tue, Dec 11 2001 at 4:24PM PST
I created the script and all works well, except I have netbarrier for x and I have typed hide and "hide" in the comments window on the alias and it will not hide it...so if anyone can help please reply...thanks...excellent script though!

[ Reply to This | # ]
Can't get App to hide
Authored by: Yertman on Tue, Dec 11 2001 at 6:06PM PST
Hi,

Just the word hide, without quotes, in the comments field should do it.

You could also try changing the script so the line that reads:
if (comment of i is "hide") then

To:
if (comment of i contains "hide") then

Also try putting the word hide in some of the other alias file's comment boxes, and see if the script hides them.

HTH
David Nelson





[ Reply to This | # ]
Some improvements
Authored by: nstanger on Thu, Dec 13 2001 at 11:40PM PST
I like this script, but after playing around with it for a little while I found a couple of things that could do with improving. First, the standard Login Items launches everything in the background, which looks much nicer (well, to me anyway). Second, if you rename the aliases (e.g., to set the launching order), process hiding no longer works because the script uses the alias name rather than the name of the original item. Actually, it's also just occured to me that the second one would also prevent you from "hiding" documents. (hack, hack :) Here's an updated version of the script that fixes these:
property pPathToLoginItemsFolder : "" -- The script will set this value.
set loginItemsList to {} -- The script will set this value.
set interLaunchDelay to 5 -- Seconds between launching applications. Feel free to fiddle with this one.
tell application "Finder"
set pPathToLoginItemsFolder to ((container of (path to me) as alias) as text) & "Login Items:"
set loginItemsList to every alias file of folder pPathToLoginItemsFolder
repeat with i in loginItemsList
delay interLaunchDelay

-- Getting the original item of the alias allows us to have aliases with different names from
-- the original items. If we don't do this, it screws up hiding processes below because the
-- process name doesn't match the item name.
set originalItem to original item of i

-- It looks nicer if applications open in the background without coming to the front.
-- Using "open" won't do this, but "launch application" will. However, we can't just use
-- "launch application" for everything because that doesn't let us include documents
-- in the login items. We therefore need to check first whether we're dealing with an
-- application file.
if (class of originalItem is application file) then
-- Odd: "launch application" doesn't work without the "tell me", don't know why.
-- We convert originalItem to a string to get the full path to the application (see
-- http://www.applescriptsourcebook.com/tips/launchbycreator.html for an
-- explanation).
tell me to launch application (originalItem as string)

-- Hide those processes that should be.
if (comment of i is "hide") then
set visible of process ((displayed name of originalItem) as text) to false
end if
else -- Not an application, so just open it.
open originalItem

-- Hide those processes that should be.
if (comment of i is "hide") then
set appName to (displayed name of application file id (creator type of originalItem)) as text
set visible of process appName to false
end if
end if
end repeat
end tell
I haven't tested it extensively, but it appears to do the job. Hope you find it useful!

[ Reply to This | # ]
Some improvements
Authored by: thatch on Wed, Dec 19 2001 at 3:15AM PST
I had some problems with another applescript login item as well as some problems with other user accounts with this tip.

An applescript I had made for moving my browser cache to the trash on login stayed open and became unresponsive when it was a run only script so I had to put it into the regular login items together with this tip script.

When I tried to use this setup in other user accounts, it wouldn't run because of a certain login item called Cookie Dog Login which is kept in ~/Library/Preferences and is listed as a document not an application. It is also in reality a carbon app. The reason it doesn't work is because it doesn't have the correct permissions being another user account.

But I do like the way this tip works for my admin account. I set the time variable to only one second and it works just fine. It's certainly better than having all the login items launch at once. And you can still control the order they launch too.

[ Reply to This | # ]
Starting other apps
Authored by: cz on Fri, Jan 4 2002 at 12:35AM PST
I have an emech that I'd like to start at boot/login. How can I get this script to launch it and similar programs?

Thanks

[ Reply to This | # ]
An AppleScript workaround for login items bug
Authored by: seasprite on Tue, Mar 27 2007 at 4:11PM PDT
I'm trying to solve a vexing problem prerquisite to using your applescript. I cannot for some reason remove items from my Login Items List. I am an admin and all of that. I click on the - and nothing happens. I have searched the hard drive looking for anything that would appear to store this information and have found nothing so far. Any idea where apple hides this info?

Thanks in advance

[ Reply to This | # ]