
Microsoft Windows folders are commonly displayed with a standard icon. This
includes the folder on the start menu*. You can customize
the appearance of this icon using a desktop configuration file named "Desktop.ini"
for the folder. IconStartMenu is a script that automatically searching the entire
folder list on your start menu and set the display icon to one that matches
it contents. It starts recursively search all the folders in the start menu
(i.e. "C:\Documents and Settings\All Users\Start Menu"). Each file in each folder
is checked to find an appearance icon. The match works in the following order
and stops when an icon match is made.
- Check to determine if it is a shortcut file (*.lnk)
- Check if shortcut icon valid
- Check if target of shortcut is a valid icon file
Once a match is made, any pre-existing desktop conf information is read in.
The icon file and index is then appended with pre-existing info to the desktop
conf file. If no prior desktop conf file exists, a new one is created. An option
is also made available to sort your start menu sorted by name. This is done
by deleting the value registry value that holds the sorted order, forcing windows
to resort the start menu. The customize icons and sorted order will not take
affect until a reboot. However, this can be overcome by right-clicking on any
folder listed in the start menu and left-clicking on "Sort by Name". Requires
* The start menu layout may differ. In this case, we
are referring to the list of programs or All programs. This does not include
options such as run, control panel, or recently used shortcuts.
Download Icon Start Menu (vbs file)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iDTfiles = 0
- CRLF = Chr (13) + Chr (10)
- sTitle = "Icon Start Menu"
-
- Welcome()
-
- Set oFSO = CreateObject ("Scripting.FileSystemObject")
- Set oWSH = CreateObject ("WScript.Shell")
-
- Start(oWSH.SpecialFolders("AllUsersPrograms"))
-
-
- Start(oWSH.SpecialFolders("StartMenu") & "/Programs")
- SortMenu()
- CreateSC()
- sMsg = "Script Is complete. " & iDTfiles & " folders have been customized."
- MsgBox sMsg, vbInformation , sTitle
-
- Sub Start(sPath)
- On Error Resume Next
- Set oFolder = oFSO.GetFolder(sPath)
- For Each Folder In oFolder.SubFolders
- SetIcon(Folder)
- Next
- End Sub
-
- Function SetIcon(oFolder)
- On Error Resume Next
- SetIcon = ""
- bFoundIcon = False
- For Each File In oFolder.Files
- If LCase (Right (file.name,3)) = "lnk" Then
- FullPath = oFolder.path & "\" & File.Name
-
- Set oLink = oWSH.CreateShortcut(FullPath)
-
- aIcon = Split (oLink.IconLocation, ",")
-
-
- If GoodIcon(aIcon(0)) Then
- SetIcon = aIcon(0) & "," & aIcon(1)
- bFoundIcon = True
- Exit For
- ElseIf GoodIcon(oLink.TargetPath) Then
- SetIcon = oLink.TargetPath & "," & 0
- bFoundIcon = True
- Exit For
- End If
- End If
- Next
- For Each Folder In oFolder.SubFolders
- SubIcon = SetIcon(Folder)
- Next
- If bFoundIcon = Fasle Then
- SetIcon = SubIcon
- End If
- If oFolder.Name = "Startup" Then
- SetIcon = "%SystemRoot%\system32\SHELL32.dll,24"
- End If
- WriteDTfile oFolder, SetIcon
- End Function
-
-
- Function GoodIcon(path)
- GoodIcon = False
-
- If LCase (Right (path,3)) = "exe" Or LCase (Right (path,3)) = "dll" Or _
- LCase (Right (path,3)) = "ico" Then
- GoodIcon = True
- End If
-
-
- If Not InStr (LCase (path), "unins") = 0 Then GoodIcon = False
- If Not InStr (LCase (path), "setup") = 0 Then GoodIcon = False
- End Function
-
- Sub WriteDTfile(Folder, sIconFile)
-
- aIcon = Split (sIconFile, ",")
- If aIcon(0) = "" Then Exit Sub
- If Not IsNumeric (aIcon(1)) Then aIcon(1) = 0
- sDTfile = Folder.path & "\Desktop.ini"
- WriteKey ".ShellClassInfo", "IconFile", SysEnvRe(aIcon(0)), sDTfile
- WriteKey ".ShellClassInfo", "IconIndex", aIcon(1), sDTfile
-
- If (Folder.Attributes And 1) <> 1 Then Folder.Attributes = Folder.Attributes + 1
-
- iDTfiles = iDTfiles + 1
- End Sub
-
- Sub WriteKey(Section, KeyName, Value, FileName)
- On Error Resume Next
-
- If oFSO.FileExists(FileName) Then
- Set fDT = oFSO.GetFile(FileName)
-
- fDT.Attributes = 0
- INIContents = ""
- Set TextStream = fDT.OpenAsTextStream(1)
- Do While Not TextStream.AtEndOfStream
- INIContents = INIContents & TextStream.ReadLine & CRLF
- Loop
- TextStream.Close
-
- If Len (INIContents) > 3 Then
- INIContents = Left (INIContents, Len (INIContents) - 2)
- End If
- Else
- INIContents = ""
- End If
-
- PosSection = InStr (1, INIContents, "[" & Section & "]")
- If PosSection > 0 Then
-
- PosEndSection = InStr (PosSection, INIContents, CRLF & "[")
-
- If PosEndSection = 0 Then PosEndSection = Len (INIContents) + 1
-
- OldsContents = Mid (INIContents, PosSection, PosEndSection - PosSection)
- OldsContents = Split (OldsContents, CRLF)
-
- sKeyName = LCase (KeyName & "=")
-
- For Each Line In OldsContents
- If LCase (Left (Line, Len (sKeyName))) = sKeyName Then
- Line = KeyName & "=" & Value
- Found = True
- End If
- NewContents = NewContents & Line & CRLF
- Next
- If IsEmpty (Found) Then
-
- NewContents = NewContents & KeyName & "=" & Value
- Else
-
- NewContents = Left (NewContents, Len (NewContents) - 2)
- End If
-
- NewContents = Left (INIContents, PosSection - 1) & NewContents
- NewContents = NewContents & Mid (INIContents, PosEndSection)
- Else
-
- If Right (INIContents, 2) <> CRLF And Len (INIContents) > 0 Then
- INIContents = INIContents & CRLF
- End If
- NewContents = INIContents & "[" & Section & "]" & CRLF & KeyName & "=" & Value
- End If
- Set TextStream = oFSO.CreateTextFile(FileName, True )
- TextStream.Write NewContents
- TextStream.Close
- Set fDT = oFSO.GetFile(FileName)
-
- fDT.Attributes = fDT.Attributes + 3
- End Sub
-
-
-
- Function SysEnvRe(path)
- SysEnvRe = path
- vars = Array ("APPDATA", "ALLUSERSPROFILE", "USERPROFILE", "ProgramFiles", "SystemRoot")
- Set SysEnv = oWSH.Environment("PROCESS")
-
- For Each var In vars
- SysEnvRe = Replace (SysEnvRe, SysEnv(var),"%" & var & "%")
- Next
- End Function
-
- Sub SortMenu()
- On Error Resume Next
- sMessage = "Would you Like your start menu sorted by name?"
- iAns = MsgBox (sMessage, vbYesNo + vbInformation , sTitle)
- If iAns = vbYes Then
- Set oShell = CreateObject ("Wscript.Shell")
- sKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu2"
- oShell.RegDelete sKey
- sKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu"
- oShell.RegDelete sKey
- End If
- End Sub
-
- Sub CreateSC()
-
- sMessage = "Would you Like To create a start menu shortcut?"
- iAns = MsgBox (sMessage, vbYesNo + vbInformation , sTitle)
- If iAns = vbYes Then
-
- sPath = oWSH.SpecialFolders("AllUsersPrograms")
- Set oSC = oWSH.CreateShortcut(sPath & "\IconStartMenu.lnk")
- oSC.TargetPath = WScript.ScriptFullName
- oSC.WindowStyle = 1
- oSC.IconLocation = "%windir%/system32/shell32.dll, 84"
- oSC.Description = "IconStartMenu"
- oSC.WorkingDirectory = sPath
-
- oSC.Save
- End If
- End Sub
-
- Sub Welcome()
- sMessage = "This script will customizes Each of the folders listed" & _
- " under programs With descriptive icons."
- iAns = MsgBox (sMessage, vbOKCancel + vbInformation , sTitle)
- If iAns = vbCancel Then
- WScript.Quit
- End If
- End Sub
Download Icon Start Menu (vbs file)