How to clear the Run box history in Windows (VBScript)
Introduction
This script sample shows how to clear the Run box history in Windows.
Scenarios
When we run a application through Win + R, there will be a record in Run box. However if there are too many records, it will be a little terrible. This script is to delete some or all of the records in Run box.
Script
Step 1: Double click the script.
Step 2: Then it will show a message like the following one.
Here are some code snippets for your reference.
On Error Resume Next
'Run script with adminsitrator
If WScript.Arguments.Count = 0 Then
Dim objSh
Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1
Else
'Declare two variables
Dim objshell, Path
'Create wscript.shell object
Set objshell = CreateObject("Wscript.shell")
'Run history registry path
Path = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\"
'Delete the key
objshell.RegDelete(path)
WScript.Echo "Delete Run box history successfully."
End If
On Error Resume Next
'Run script with adminsitrator
If WScript.Arguments.Count = 0 Then
Dim objSh
Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1
Else
'Declare two variables
Dim objshell, Path
'Create wscript.shell object
Set objshell = CreateObject("Wscript.shell")
'Run history registry path
Path = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\"
'Delete the key
objshell.RegDelete(path)
WScript.Echo "Delete Run box history successfully."
End If
Windows 7 or later version
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.