How to clear ie cache, history, and cookies

Source: Internet
Author: User

Today, the customer strongly urged to add the IE cache clearing function to the software. Well, it's done with batch processing,CodeIt's quite disgusting. Remember it.

Java code:

 String cmd  =     "  CMD/K set \  "  Z  =  Hkcu \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Shell Folders \  "  &  For % A in (Cache history cookies) Do (for/f \  " Tokens  =  2  *  \  "  % B in (\ 'reg QUERY \  "  %  Z  %  \  "  /V % A \ ') Do (if exist \  "  %  C \  " (RD/S/Q \  "  %  C \  "  & MD \  "  %  C \  "  )))  "  ;
Process Process = Runtime.getruntime(cmd.exe C (CMD );

The general principle is to use the CMD command to read the location of the IE cache folder in the Registry (this location may vary with users, and even users can set it by themselves, and all files can only be read in the registry ), then clear the files in the folder.

========================================================== ====

Note: The preceding batch processing command cannot completely clear all files.

This is because there is a hidden folder in the cache, history, and cookies directory of IE.Content. ie5 is a file named index. dat in this folder, which stores all Internet addresses you have accessed. Because the assumer.exe Process maintains the reference of index. dat, when the file is deleted, the system prompts that the file is being opened by another process.

Fortunately, Windows provides functions for browsing and deleting the file in wininet. H. For details, see

《A cleanup API for Windows"

This articleArticleThe author also provided an encapsulated dll/COM interface that can be called directly !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.