Did you notice that in Windows XP it takes exactly half a dozen mouse clicks to clear the Recent Documents history in the new Start menu. This is the option that I’m talking about:

One of our readers asked "I need a batch file or script to clear the recent documents list from the Windows XP Start Menu". This is a legitimate request. So, here is a VBScript that’ll automate the work for you. It works in Windows XP, Windows Vista and Windows 7. Note that if you’re using Windows Vista/7, there is no real need for such a script, because you can do it directly from the Start menu. (Click Start, right-click Recent Items, and then click Clear Recent Items List)

Script to Clear Recent Documents History (Windows XP/Vista/7)

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")
end if

Instructions

Copy the above code to Notepad, and save the file with .vbs extension. (e.g. clearrecent.vbs) You can then move this script to your Quick Launch folder for easy access. Note that if you create a shortcut of the script in the Quick Launch folder, you can even customize the icon if you’re bored of seeing the default Windows Script icon.


Related Posts


Email SubscriptionPrefer an E-mail subscription?

Enter your email address:

Delivered by FeedBurner

7 Comments

  1. mike
    said this on Sunday, March 20th 2011 10:42 am

    i appreciate it…very helpful thanks !!!!!

  2. said this on Tuesday, November 2nd 2010 12:33 pm

    @markinboone: Using CCleaner is a good idea in this case. (REF: http://www.winhelponline.com/blog/add-ccleaner-button-to-internet-explorer-toolbar/) You can add “CCleaner.exe /auto” in a script/batch file.

  3. markinboone
    said this on Tuesday, November 2nd 2010 1:21 am

    I have found something in Windows 7 that is annoying regarding history files. I run a file search (I hate the new file search!) for “.mp4″ Of course, this doesn’t just find files that have “.mp4″ – Windows 7 doesn’t think I really meant to look for the period, so anything with “mp4″ anywhere shows up. (Enough of the unrelated griping.) What I get is a list of items that includes file names like “trailer.mp4″ but there is no other information showing in the Detail file view: no date, no size, no folder; and right-clicking doesn’t give me any functionality but Open, Add to Favs, Copy, Delete, Properties.
    - Properties shows it’s an “internet shortcut” and points to the location the file was downloaded (saved) to.
    - Delete doesn’t work, nor any other method to delete the “file.” A msg says “Are you sure you want to delete History Item blahblah?” but clicking yes does nothing.
    - These all have a globe icon.
    - I can copy the object, paste it into another folder, and it becomes an actual shortcut – with all the functionality! I can delete what I copied.

    These are apparently recent documents/internet history shortcuts of files I downloaded, which is disconcerting since I use FireFox and not IE. So the Operating System is tracking downloads on top of the browser doing it. Clearing (Firefox) Browser Internet History doesn’t get rid of them.

    And the script you provide doesn’t clear these buggers either. What deletes them is: Control Panel > Internet > General > Browsing History > Delete… (everything checked but Preserve Favorites website Data, Form Data, and Passwords)

    I found this shortcut on line: Create a New Shortcut, and enter for Type the Location of the Item: RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

    Is there a way to execute this in your script? The number at the end can be modified to specify exactly what to delete (http://social.answers.microsoft.com/Forums/en-US/vistaprograms/thread/a3a91631-f471-495c-af32-6ec421d0e5d9/). As it stands I’m running both the script and the shortcut to wipe out the past.

  4. Daron Johnson
    said this on Sunday, August 1st 2010 4:19 am

    Thank you, works great

  5. Greg Robert
    said this on Monday, April 19th 2010 8:55 am

    Wow, such quick help!

    Have modified my version and tested and all is well.

    Thanks Ramesh!

    - Greg

  6. said this on Monday, April 19th 2010 8:44 am

    @Greg: Updated the script in article.

  7. Greg Robert
    said this on Monday, April 19th 2010 8:04 am

    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

Leave a Reply