Clean Up the Windows Start Menu

Sometimes after installing a setup.exe with limited command line switches, we may want to clean up the Windows start menu.  Usually as part of our Application Packaging best practises we remove ‘Uninstall’ shortcuts, ‘Update’ shortcuts, and shortcuts to readme’s and help files.  This tidy script (tested on Windows 7) can be used to populate file(s) and folder(s) names that require deleting.

Clean Up the Windows Start Menu

Option Explicit

dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject") 
dim objShell : Set objShell = CreateObject("WScript.Shell") 

dim strProgramsPath : strProgramsPath = objShell.ExpandEnvironmentStrings("%AllUsersProfile%") & "\Microsoft\Windows\Start Menu\Programs"

'delete an array of files (shortcuts) from the start menu
dim arrFilesToDelete : arrFilesToDelete = Array( _
	strProgramsPath & "\Folder1\Link1.lnk", _
	strProgramsPath & "\Folder1\Link2.lnk", _
	strProgramsPath & "\Folder2\Link3.lnk", _
	strProgramsPath & "\Folder2\Link4.lnk" _
	)

dim strFile
For Each strFile In arrFilesToDelete
	If objFSO.FileExists(strFile) Then objFSO.DeleteFile strFile, True
Next

'delete an array of folders from the Start Menu
dim arrFoldersToDelete : arrFoldersToDelete = Array( _
	strProgramsPath & "\Folder1", _
	strProgramsPath & "\Folder2" _
	)

dim strFolder
For Each strFolder In arrFoldersToDelete
	If objFSO.FolderExists(strFolder) Then objFSO.DeleteFolder strFolder, True
Next

Set objFSO = Nothing
Set objShell = Nothing