Script: Autosorting start menu entries in Windows XP

One of the most annoying things in Windows is that start menu entries don’t get sorted alphabetically by default. I mean, sure… there is a practical reason for this and I won’t deny that reordering the items can be useful at times.

For my primary usage though — it is not. So I spent some time into a simple script, made of two units: a batch file that acts as the "caller" and a VBscript that’ll do some nitty gritty plumbing (actually not too much, though 😉 ).

It is based on the works featured in Script Guy, so without further ado:


On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu2"

Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")

DeleteSubkeys HKEY_CURRENT_USER, strKeypath
objRegistry.CreateKey HKEY_CURRENT_USER, strKeyPath
MsgBox "Done!"

Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath)
objRegistry.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubkeys

If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey
End If

objRegistry.DeleteKey HKEY_CURRENT_USER, strKeyPath
End Sub

DoMenuAutoSort.bat (or whatever you like to call it):

@echo off
set PATH=%PATH%;%CD%\$sys

wscript //B startmenuautosort.vbs
subinacl /subkeyreg "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu2" /deny=Jeder=F > nul

exit 0

Please note for this script to work you’ll need the Subinacl utility from Microsoft, placed into a subfolder below the script called $sys. Don’t worry, even though the utility comes as an .MSI installer you can simply copy it from your Program Files and place it in the $sys subdirectory and it’ll work on other systems.

Basically this whole thing deletes all entries under Start Menu 2 in the registry and denies any privilegue to the key. Please also note that in the German version of Windows XP the world group is called Jeder, so change it according to your needs.

About Tsukasa

The fool's herald.
This entry was posted in Blog. Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.