Clear Recent Files history Using Script in Windows 10

Did you notice that in Windows it takes exactly half a dozen mouse clicks to clear the recent items history? This post has a VBScript to clear the recent documents history in a single click in Windows 10 and earlier.

Clear Recent Files history in Windows

In Windows 10, here is the procedure to clear the recent files history which appears in Quick access home view:

  1. Open File Explorer to Quick access
  2. Right-click Quick access icon and click Options
  3. To clear recent files history, uncheck Show recently used files in Quick access
  4. Click Apply
  5. Re-enable Show recently used files in Quick access
  6. click OK

Note: In Step 3 above, you can also click on the Clear button shown in that dialog. But, it also clears the Frequent folders list in Quick access.

remove quick access in windows 10 v1607


Clear recent files history using VBScript

Pick one of the following VBScripts below to clear the recent files history on your Windows 10 computer. The script works in any version of Windows, though.

  1. Copy any one of the following script codes to Notepad.Script 1
    Const sRecent = 8
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(sRecent)
    iClr = 0
    Set objFolderItem = objFolder.Self
    For Each objVerb In objFolderItem.Verbs
    	If InStr(LCase(objVerb.Name), "c&lear recent items list") Then
    		objVerb.DoIt
    		iClr = 1
    		Exit For
    	End If
    Next
    If iClr = 0 Then MsgBox "Could not clear Recent items."

    Script 2 (alternate method)

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    sRD = WshShell.SpecialFolders("Recent")
    if sRD <> "" then
        On Error Resume Next
        objFSO.DeleteFile(sRD & "\*.lnk")
        objFSO.DeleteFile(sRD & "\*.url")
    end if
  2. Save the file with .vbs extension — e.g., clear_recent_files_history.vbs
  3. Double-click the script file to clear recent files history.

Note that you can pin the shortcut to the script to the Start or Taskbar, and customize the shortcut icon if you’re bored of seeing the default Windows Script icon.

The above scripts work in any version of Windows, including Windows 10. But, if you’re using Windows 7, there is no need for such a script, because you can do it directly via Start → right-click Recent Items → click Clear Recent Items List.

Clear Quick access Frequent folders and Recent files history

To clear the Quick access frequent folders and recent files history, open the Folder Options dialog and click the Clear button.



clear quick access history

The pinned items in the Quick access won’t be removed.

To automate the above, you can use the following AutoHotKey script/macro:

AutoHotKey script to clear Quick access history

Run, control.exe folders
WinWait, ahk_class #32770
WinActivate, ahk_class #32770
WinWaitActive, ahk_class #32770
Send, !c {Esc}

Install AutoHotKey on your computer. Then, using Notepad, create a script file with the above contents. Save the file as clear_quick_access_history.ahk and double-click the file to run it. The script launches Folder Options, clicks the Clear button automatically and closes Folder Options.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support, my reader. It won't take more than 10 seconds of your time. The share buttons are right below. :)

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and he has been a Microsoft Most Valuable Professional (MVP) for 10 consecutive years from 2003 to 2012.

11 thoughts on “Clear Recent Files history Using Script in Windows 10”

  1. Ramesh,

    Oh, I see the bug. sRD is the pathname to the recent files folder. However, since the folder always exists, the test is always true, even if the folder is empty. So it always tries to delete the links and, when there ARE NO links, it gets an error.

    Is there a way to suppress the error and continue execution?

    – Greg

    Reply
  2. I am getting an ‘Invalid character’ error when I am running this on my windowsXP.
    Don’t know the reason behind it. It’s opening the file using “Windows Script Host”.

    Reply
  3. Thnks very very much for this. I’ve always been going through the usual very long way around to this, and it really does help keep a Windows XP computer running quicker, especially when copying lots of files around. I just never got around to searching for a better way.

    Very much appreciated 🙂

    Reply

Leave a Comment