<

Script to Delay and Stagger the Launch of Login Items Under OS X

Published on
10,190 Points
4,190 Views
Last Modified:
Approved
If you are using Mac OS X and have a large number of login items set up in accounts, under system preferences, you may find that your computer is sluggish and unresponsive during startup until everything is done launching.

Another problem that arises from time to time is that a login item fails because it requires a resource that is not ready.

The attached script enables you to defer and stagger any or all of your startup items, to alleviate these issues.

Note: It works with a mechanism similar to the OS 9 (and earlier) startup items folder.


How to use the script:
1. make a new folder named "staggeredlaunchitems" in your preferences folder (the one in the library in your home directory).

2. put aliases of the files you want to open or applications you want to launch into the staggeredlaunchitems folder.

3. launch AppleScript editor and paste the attached code snippet into a new AppleScript:
-- this script emulates the OS 9 (and earlier) startup items folder, with the added ability to stagger and delay launches
-- to use this script, 
--   1. make a new folder in your preference folder (the one in the library in your home directory) called (exactly)
--       staggeredlaunchitems
--   2. put aliases of the files you want to open/applications you want to launch into the staggeredlaunchitems
--   3. customize the delays, if desired, in the two "set" commands at the top of the script
--   4. save this script as an application, and make it a login item in (in accounts under system prefs)

set launchdelay to 10 -- change this as required to customize the number of seconds before the first item launches
set itemdelay to 5 -- change this as required to customize the number of seconds between launches

tell application "Finder"
	set launchitemsfolder to (path to preferences folder as string) & "staggeredlaunchitems"
	delay launchdelay
	repeat with x from 1 to (the number of files of folder launchitemsfolder)
		set thefile to (file x of folder launchitemsfolder) as string
		do shell script "open " & (quoted form of POSIX path of thefile)
		delay itemdelay
	end repeat
end tell
quit

Open in new window


4. customize the delays, if desired, in the two "set" commands at the top of the script.
launchdelay -- the number of seconds before the first item launches.
itemdelay -- the number of seconds between each item's launch.

5. save the above script as an application, and make it a login item in accounts, under system preferences.

6. any login items that are now being launched by the script should be removed from the login items pane in accounts, under system preferences.


The files in your staggeredlaunchitems folder will now launch in accordance with the set delays. They will launch in alphabetical order according to the names of the aliases. Change the names of the aliases to change the launch order.

0
Comment
Author:nxnw
0 Comments

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Join & Write a Comment

This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A query can call a function, and a function can call Excel, even though we are in Access. This is Part 2, and steps you through the VBA that "wraps" Excel functionality so we can use its worksheet functions in Access. The declaration statement de…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month