Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Start Menu and Favorites in Alphabetical Order

Status
Not open for further replies.

utilman

IS-IT--Management
Dec 25, 2002
35
NL
Does some know some code to Sort Start Menu and Favorites in Alphabetical Order on the fly (sendkey or something like that) ?
 
Thx for the reply tsuji !
But I'm looking for a way to build that function in VBS so I can let it run while users logging in. Do you know the code for this? Can remember that I saw it once with some sendkey commands. A shame that deleting certain registry keys is not enough anymore ;)
 
utilman,

Per #196, it is the subkey in .reg to be deleted.
Code:
Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites]

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu]

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu2]
But, these things are os-dependent. The q-article indicates the general locations to look for.

- tsuji
 
I know. And I can't do this with RegDelete so I have a different code for this. However, this only works after you restart your computer or maybe login again. I'm looking for a way to do this on the fly. So without a logoff and login...

Code:
Const HKEY_CLASSES_ROOT  = &H80000000
Const HKEY_CURRENT_USER  = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS         = &H80000003

' Object used to get StdRegProv Namespace
Set wmiLocator = CreateObject("WbemScripting.SWbemLocator")

' Object used to determine local machine name
Set wshNetwork = CreateObject("WScript.Network")

' Registry Provider (StdRegProv) lives in root\default namespace.
Set wmiNameSpace = wmiLocator.ConnectServer(wshNetwork.ComputerName, "root\default")
Set objRegistry = wmiNameSpace.Get("StdRegProv")

' Deletes Key with alle subkeys
sPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites"

lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath)

Function DeleteRegEntry(sHive, sEnumPath)
' Attempt to delete key.  If it fails, start the subkey
' enumration process.
lRC = objRegistry.DeleteKey(sHive, sEnumPath)

' The deletion failed, start deleting subkeys.
If (lRC <> 0) Then

' Subkey Enumerator
   On Error Resume Next

   lRC = objRegistry.EnumKey(HKEY_CURRENT_USER, sEnumPath, sNames)

   For Each sKeyName In sNames
      If Err.Number <> 0 Then Exit For
      lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName)
   Next

   On Error Goto 0

' At this point we should have looped through all subkeys, trying
' to delete the registry key again.
   lRC = objRegistry.DeleteKey(sHive, sEnumPath)

End If

End Function

' Deletes Key with alle subkeys (repeat)
sPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu2"

lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath)

Function DeleteRegEntry(sHive, sEnumPath)
' Attempt to delete key.  If it fails, start the subkey
' enumration process.
lRC = objRegistry.DeleteKey(sHive, sEnumPath)

' The deletion failed, start deleting subkeys.
If (lRC <> 0) Then

' Subkey Enumerator
   On Error Resume Next

   lRC = objRegistry.EnumKey(HKEY_CURRENT_USER, sEnumPath, sNames)

   For Each sKeyName In sNames
      If Err.Number <> 0 Then Exit For
      lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName)
   Next

   On Error Goto 0

' At this point we should have looped through all subkeys, trying
' to delete the registry key again.
   lRC = objRegistry.DeleteKey(sHive, sEnumPath)

End If

End Function



MsgBox "Registry keys are deleted"
 
utilman,

Yes, that is a perpetual problem for this kind of approach. That's why the setting of the kind is not suitable to deal with via login script. Furthermore, the user may not have sufficient rights to manipulate the keys.

For the case where security is not a prime concern, you may experiment with a api wrapper to broadcast a systemchange message to top-level windows. I occasionally used dynawrap for experimentation of this kind. Take a look of a previous thread I'd participated:
Maybe you'll find some inspiration.

- tsuji
 
I was more or less thinking of the sendkey function with

1. Windows key
2. All Programs
3. Right mouse
4. Sort on name

But since I do not know alle the right sendkey commands, I thought that maybe someone else knew ;)

Do you ??
 
Where can I find all the sendkey option anyway. And is there a program which can record those commands ??
 
utilman,

Sendkeys page of the documentation script56.chm is reasonably informative. As to record those commands like recording a macro in office, no in the native package.

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top