Clear cache using batch file for windows 7 and above

Shantanupatel
Posted by in Others category on for Beginner level | Points: 250 | Views : 33644 red flag
Rating: 5 out of 5  
 3 vote(s)

To clear the browser cache which gets stored in the temporary location of the machine when the URL is hit on the browser using a batch file.


 Download source code for Clear cache using batch file for windows 7 and above

Define Cache?

As and when you access your browser and hit an URL, the browser renders the request and stores the files in the temporary location of the machine. (Temporary Internet files). You should clear the cache for better performance of the machine.

Explain cookie and history?

Cookie is a file that is created by a web browser as the URL is rendered in the Temporary Internet files folder. Cookies stores user related info. If the cookies expiration is set it would get cleared at that point of time or else the browser automatically clears it when it is closed.

Browser's history is a log of various URL of sites that you visit on your machine.


Using the code

@ECHO OFF 
Echo Clear Cache for Windows 7
Echo Removes temporary files FROM ALL PROFILES.
Echo.
Echo Temporary files will be removed from the following locations:
Echo.
Echo   1. [Profile]\AppData\Local\Microsoft\Windows\Temporary Internet Files
Echo   2. [Profile]\AppData\Local\Microsoft\Windows\History
Echo   3. [Profile]\AppData\Local\Microsoft\Windows\Temp
Echo   4. [Profile]\Cookies
Echo   5. [Profile]\Recent
Echo   6. [SystemRoot]\Temp
Echo.

Echo Note: 255 is for Deletes ALL History, 1 is for Deletes History Only, 2 is for Cookies, 8 is for Temporary Internet Files, 16 is for Form Data and 32 is 

for Passwords.

Echo.
Echo Press Ctrl+C to abort or any other key to continue . . .
Echo.

PAUSE > NUL
:: Clear local Temporary Internet Files and History
Echo.

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 (Deletes ALL History)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1 (Deletes History Only)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 (Deletes Cookies Only)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 (Deletes Temporary Internet Files Only)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 (Deletes Form Data Only)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 (Deletes Password History Only)

Echo Temporary Internet Files and History Deleted Successfully!
Echo.
Echo Press any key to continue . . .
PAUSE > NUL
EXIT
Output of the executed Window
Page copy protected against web site content infringement by Copyscape

About the Author

Shantanupatel
Full Name: Shantanu Patel
Member Level:
Member Status: Member
Member Since: 2/19/2010 8:01:15 AM
Country: India
Shantanu
http://www.dotnetfunda.com

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)