Friday, July 10, 2009

VBScript: Sort Start Menu Items


Const optionType = 1
Const regBase = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder"

Set objShell = CreateObject("Wscript.Shell")

If optionType = 1 Then
' a sloppy, cheap, but effective way to do this with Wscript
cmd1 = "start /wait reg delete """ & regBase & "\Start Menu"" /f"
cmd2 = "start /wait reg delete """ & regBase & "\Start Menu2"" /f"
cmd3 = "start /wait taskkill /im explorer.exe /F"
cmd4 = "explorer.exe"
objShell.Run "cmd.exe /c " & cmd1, 1, True
objShell.Run "cmd.exe /c " & cmd2, 1, True
objShell.Run "cmd.exe /c " & cmd3, 1, True
objShell.Run "cmd.exe /c " & cmd4, 1, True
Else
' a more elegant, poofy and girly way of doing this with style and ambiance
objShell.RegDelete regBase & "\Start Menu\"
objShell.RegDelete regBase & "\Start Menu2\"
objShell.Run "cmd.exe /c start /wait taskkill /im explorer.exe /F", 1, True
objShell.Run "cmd.exe /c explorer.exe", 1, True
End If

Set objShell = Nothing

No comments:

Post a Comment