Filed under: Terminal Tips, Leopard
Terminal Tips: Rebuild your Launch Services database to clean up the Open With menu
Problem: Some piece (or pieces) of rogue software have cluttered up your Open With contextual menu, which you can see by right-clicking or control-clicking any document in the Finder. This problem seems to be most prevalent with virtual machines that allow you to open documents with Windows applications, but tend not to clean up after themselves. After having both Parallels and VMWare installed on my MacBook Pro, my Open With menu was a mess.
Solution: Lucky for me, I noticed David Chartier's question about this on Twitter around the same time as I was wondering what to do about it. Some friendly person pointed him to a posting on Apple's discussion forum (also noted on Mac OS X Hints here and here), noting that running a specific command in a terminal window will rebuild your launch services, which repopulates the Open With menu with a current list of applications, without duplicates. It worked perfectly for me, but beware, on my system it took about 10 minutes to complete, and I suspect it could take more on a sufficiently gummed-up system.
Here's the Leopard version of the command (the path to the tool is different in Tiger, see here). I broke it into three lines for readability, but the \ at the end of the line is bash-speak for "keep on going with the same command" -- you can copy and paste it directly and it should work, or if you type it on one line without the backslashes, it will also work fine.
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\
LaunchServices.framework/Versions/A/Support/lsregister -kill\
-r -domain local -domain system -domain user
If, preferring to avoid the Terminal, you want a handy GUI app to rebuild the Launch Services database with a couple of clicks, check out Titanium's OnyX or Maintenance utilities, both free of charge.

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
Willson said 5:25PM on 6-11-2009
Someone did something silly with their text...
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\ LaunchServices.framework/Versions/A/Support/lsregister -kill\ -r -domain local -domain system -domain user
is waaaaaay past the boundaries.
Reply
Michael Rose said 5:30PM on 6-11-2009
Lost some breaks in the edit. Fixed!
Greg said 5:34PM on 6-11-2009
Fantastic post, thanks!
Just a note on both my machines (mac pro with a 3 disk striped RAID and a C2D mac mini) this took ~30 seconds to run. Your machine must have an insane amount of applications for it to take 10 minutes!
Reply
damian.claassens said 6:01PM on 6-11-2009
Great post. Another easy to use tool to rebuild your Launch Services database, for those shy of delving into Terminal commands, is Cocktail. Similar to Onyx. You can get it from here: http://www.maintain.se/cocktail/index.php
Reply
tukan said 6:04PM on 6-11-2009
for some reason it would not work for me when not in one line - probably an issue with the copying - thanks a lot, I was just annoyed today by double entries and old junk
Reply
Robert said 8:45PM on 6-11-2009
Unfortunately, it didn't help with my "DashCode is the ruler of .css files and no matter what you do, you will never be able to override it!" problem. I've tried file information:Open With:Change All (with and without Always Open With checked), and right click:Open With:Other (with and without Always Open With checked). Neither worked. If anyone knows of anything other than uninstalling DashCode, please let me know. I want to punch my computer in the face every time DashCode opens my CSS files instead of Smultron. Of course, I may just have to uninstall DashCode and hate Apple for not obeying their own rules.
Reply
maccamb said 11:04AM on 6-15-2009
Onyx is another wonderful, free app that can rebuild Launch Services.
Reply
lmo said 10:14AM on 6-12-2009
When I ran that, I got this error: SystemFlippers: didn't consume all data for vers ID 1 (pBase = 0x2cd54, p = 0x2cd66, pEnd = 0x2cd67)
Ideas? I can say that it seems to have worked, anyway.
Reply
Aaron said 11:44AM on 6-12-2009
THANK YOU!! I've been wondering how to fix this problem for years now, heh.
Reply
Brett said 1:41PM on 6-13-2009
Great tip, thanks.
Reply
roger said 5:37PM on 9-03-2009
Inquiring minds want to know..
Why does the LaunchServices Database need to be rebuilt? What causes it?
eg I have imacs dual booting to 10.5 and XP. I'd like to blame XP for corrupting the LS but I can't figure out how it would.
Help?
Reply