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 !!!