4

How do I move an item above the separator line in the New submenu of Windows 10's right-click context menu?

Is there anything in the Registry that needs to be set?

Right Click Menu Example

2 Answers 2

7

Create a Config subkey under the ShellNew key of your file type. Then inside that subkey, add a string value named BeforeSeparator. The change should take effect immediately:


To figure this out, I had to dive into the Explorer code. shell32.dll contains a CNewMenu class that represents the New menu and has a function named _BeforeSeparator that determines whether the given entry should be placed before the separator. Here's the important part of that function's disassembly (courtesy of IDA):

First it uses PathMatchSpecW to see if the key name is one of .lnk, .library-ms, or Folder. If it is (red/left path), the item is guaranteed to appear above the line. If not (green/right path), the function checks whether a certain bit (10h) in a certain part (+8) of the data structure is set.

I needed to find the code responsible for setting that bit. There's a function called _GetNewObjectInfoForKey that seems to be responsible for setting up the relevant data structures. Here's part of its disassembly, almost right at the beginning:

It tries to open a subkey called Config and, if successful (red path), uses the _GetConfigFlags function to set the part of the data structure containing the bit we're interested in! _GetConfigFlags goes along testing for the existence of various entries and setting various bits if appropriate. Here's the part that sets our target bit (10h):

And there we see the desired entry name: BeforeSeparator.

2
  • 3
    +1 for the assembly. Context menu registry changes can be applied with Explorer restart (without rebooting).
    – Biswapriyo
    Commented Nov 23, 2018 at 3:01
  • 1
    Very useful answer, thanks for sharing. Commented May 31, 2021 at 12:35
0

If someone needs the registry file to add new folder with date here it is

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\.NewDirectoryBasedOnDate]
@="NewDirectoryBasedOnDate"

[HKEY_CURRENT_USER\Software\Classes\.NewDirectoryBasedOnDate\ShellNew]
"Command"="\"CMD\" /D /E:ON /c for /F \"tokens=1-9 delims=.,\\:/\" %%A IN (\"%%date%%\") DO for /F \"tokens=*\" %%a IN (\"%1\") do md \"%%~dpa\\%%A.%%B.%%C\""
"nullfile"=hex:

[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate]
"FriendlyTypeName"="New Folder With Date"

[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate\DefaultIcon]
@="shell32.dll,3"

[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate\Shell\open]
"LegacyDisable"=hex:

[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate\Shell\open\command]
@="."

[HKEY_CURRENT_USER\Software\Classes\.NewDirectoryBasedOnDate\ShellNew\Config]
"BeforeSeparator"=""

Save it as folderwithdate.reg and run it.

1
  • Not sure if this was meant for this question, but this is a cool regedit, thanks. Commented May 31, 2021 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .