'EditRunMRUList.vbs
'Selectively clears individual items from the Start  - Run dialog box MRU list.
'
'
On Error Resume Next
strExplain="Edit Run MRU List will remove individual items from the Start - Run MRU (a list of recently run commands)." & vbCRLF & "The program will prompt for each item in the list." & vbCRLF & vbCRLF
strTitle="Edit Run MRU List"

Dim Sh
Set Sh = WScript.CreateObject("WScript.Shell")
ReportErrors "Creating Shell"
Sh.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\" & Wscript.ScriptName & "\", Chr(34) & Wscript.ScriptFullName & Chr(34) 
Sh.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\" & Left(Wscript.ScriptName, Len(Wscript.ScriptName)-3) & "exe" & "\", Chr(34) & Wscript.ScriptFullName & Chr(34) 
ReportErrors "Updating App Paths"
MRUList=Sh.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\MRUList")
If Err.Number=-2147024894 then 
	Err.Clear
	MRUList=0
Else
	MRUNo=Len(MRUList)
End If

If MsgBox (strExplain & "Number of entries" & vbtab & MRUNo & vbCRLF & vbCRLF & "Do You Wish to Edit the RunMRU list now?", vbYesNo + vbInformation, strTitle) = 6 then
	Dim MRUItem()
	ReDim Preserve MRUItem(0)
	For x=0 to MRUNo - 1
		MItem=Sh.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\" & Mid(MRUList,x+1,1))
		Sh.Regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\" & Mid(MRUList,x+1,1)
		If MsgBox ("Do you want to delete " & vbcrlf & vbcrlf & Left(MItem,Len(MItem)-2) & vbcrlf & vbcrlf & "Yes" & vbtab & "To delete" & vbcrlf & "No" & vbtab & "To keep", vbYesNo + vbQuestion, strTitle) <> 6 then
			ReDim Preserve MRUItem(UBound(MRUItem)+1)
			MRUItem(UBound(MRUItem))=MItem
		End If
	Next
	MRUList=""
	For y=1 to UBound(MRUItem) 
		MRUList=MRUList & Chr(y + 96)
		Sh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\" & Chr(y + 96),MRUItem(y)
	Next
	Sh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\MRUList", MRUList
	Msgbox "Click Start - Turn off Computer then Restart to allow changes to take effect.", vbInformation + vbOKOnly, strTitle
End If


PCHell
ReportErrors(test)

Sub ReportErrors(strModuleName)
	If err.number<>0 then Msgbox "An unexpected error occurred. This dialog provides details on the error." & vbCRLF & vbCRLF & "Error Details " & vbCRLF & vbCRLF & "Script Name" & vbTab & Wscript.ScriptFullName & vbCRLF & "Module" & vbtab & vbTab & strModuleName & vbCRLF & "Error Number" & vbTab & err.number & vbCRLF & "Description" & vbTab & err.description, vbCritical + vbOKOnly, "Something unexpected"
	Err.clear
End Sub


Sub PCHell
	If MsgBox("This script was downloaded from PCHell.com" & vbCRLF & vbCRLF & "Would you like to visit PCHell.com?", vbQuestion + vbYesNo + vbDefaultButton2, "PCHell.com") =6 Then
		sh.Run "http:\\www.pchell.com"
	End If
End Sub
