Why does Explorer’s New menu take so long to appear the first time I open it?

Raymond Chen

Raymond

When you right-click on an empty space in an Explorer folder and select the New menu item, there is sometimes a delay of up to two seconds before the menu appears. What’s going on during that delay?

The items in the New menu are discovered by looking for Shell­New subkeys in HKEY_CLASSES_ROOT.

This search takes some time, seeing as HKEY_CLASSES_ROOT is a rather large registry key. The New menu starts a background task to collect all the information and waits up to two seconds for it to report results. If the task doesn’t finish within two seconds, then the New menu gives up waiting and merely shows the result from the previous time the task ran, hoping that no new items were added in the meantime.

Meanwhile, the task continues to run and eventually completes with a list of items. If it finishes in time, the New menu will use it right away. Otherwise, it is saved for the New menu to use next time.

This is the similar sort of nonsense we went through with the COM component category catalog.

Raymond Chen
Raymond Chen

Follow Raymond   

13 Comments
Avatar
George Gonzalez 2019-05-28 07:19:53
Yeah, every time I wait for that menu to appear, I think:  The first computer I worked on had a 80KHz basic instruction time.  This one runs at 3.2GHz  with six cores.  Two seconds on this one is the equivalent of about two million seconds on that first CDC 160A.  That would be like very roughly 23 days to wait for that menu.  Good thing it didn't have a registry!
Avatar
Steven Don 2019-05-28 07:50:00
What is meant by "the first time"? The first time in an Explorer session? The first time in a given folder? The first time during the time the Explorer context menu is open? A simple test I just did implies the latter. I admit to getting a little annoyed when I just want to create a new folder and have to wait several seconds for the menu to pop up. Yes, I should probably use the button in the ribbon instead, but it is hard to change the muscle memory.
Avatar
Joshua Schaeffer 2019-05-28 10:05:55
It took me about 100-200 lines of C# to recreate the enumeration and construction of the New menu but I was hoping there was a way Windows could do it for me similar to IContextMenu. I hand you a folder PIDL/IShellItem and a menu handle, you fill it with New items, and then I tell you which command to activate. Everyone who creates their own Explorer replacement (or Open/Save As window) has the conundrum of being able to offer in-place creation of items. They all do it differently and nobody does it well.
Avatar
Dmitry Vozzhaev 2019-05-28 11:26:12
And in such indices, althougo small pricks To their subsequent volumes, there is seen The baby figure of the giant mass Of things to come at large. You know, caching is only one of two methods to speed up lookup queries. 
Avatar
"Fleet Command" 2019-05-28 23:00:15
Somehow, I don't think you are talking about the Windows 10 v1809 bug that causes the New menu to appear after a long delay, every time. Microsoft says this issue has been resolved in 1903.
Avatar
Marc K 2019-06-22 13:39:32
This is super annoying.  I'd prefer if Explorer did the scan at startup (or soon after) and then used RegNotifyChangeKeyValue to update as things change.  My computer will be running for days and I'll still regularly find myself waiting for 3 seconds for the New menu.