I was using the following script to delete the browsing history in IE 7.0
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
But now I need a script to clear browsing history in IE 6.0
I get an error that "missing entry ClearMyTracksByProcess" I have passed different parameters like 2 ,5 etc and wasn't successful.
// test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "test.h"
#include <shlguid.h> // Needed for CLSID_CUrlHistory
#include <urlhist.h> // Needed for IUrlHistoryStg2 and IID_IUrlHistoryStg2
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
IUrlHistoryStg2* pHistory; // We need this interface for clearing the history.
HRESULT hr;
DWORD cRef;
CoInitialize(NULL);
// Load the correct Class and request IUrlHistoryStg2
hr = CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER,
IID_IUrlHistoryStg2, reinterpret_cast<void **>(&pHistory));
if (SUCCEEDED(hr))
{
// Clear the IE History
hr = pHistory->ClearHistory();
}
// Release our reference to the
cRef = pHistory->Release();
CoUninitialize();
}
return nRetCode;
}
Since INETCPL.CPL version 7.0
that ships with Internet Explorer 7 does have an entry-point named ClearMyTracksByProcessW
, It's possible it is not present in IE6.
Hence may be a script is a more basic solution:
@ECHO OFF
ECHO * Cleaning Current User's Temp Folders *
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Cookies\*.*"
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\Temp\*.*"
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\History\*.*"
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\Temporary Internet Files\*.*"
Echo * Done *
PAUSE
CLS
(you can keep only the "delete" that interest you in this script)
However, as reported in this thread, it may not be enough.
The only other solution would be to use a (free) thirdparty utility:
alt text http://www.ccleanerbeginnersguide.com/ccleanerhelp.pngCCleaner
Other options are mentionned in this thread:
- index.dat
- Xp Tweaks (See 24 right)
ClearMyTracks() was not part of IE6, so you cannot do the same trick.
If you just want to clear history, you can write a small program that just CoCreates(CLSID_CUrlHistory, IID_IUrlHistoryStg2) and then call IUrlHistoryStg::ClearHistory().
Should be able to do it from VBScript as well, but I don't know the right mojo.
Bad news folk's
Trying to delete internet history using ClearMyTracksByProcess on Win 7 with IE8/9 no longer works and you can only clean some of the files by running dos delete commands at startup because microsoft uses super hidden folders, locks files, well it a big mess and upsets Big Brother.
This code cleans IE8/9 plus FireFox and shared objects/flash cookies but if you want to delete Index.dat files then click my name to see the code.
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Text;
namespace Fidling
{
public static class SpywareRemoval
{
private static void RemoveSpywareFiles(string RootPath, string Path,bool Recursive)
{
string FullPath = RootPath + Path + "\\";
if (Directory.Exists(FullPath))
{
DirectoryInfo DInfo = new DirectoryInfo(FullPath);
FileAttributes Attr = DInfo.Attributes;
DInfo.Attributes = FileAttributes.Normal;
foreach (string FileName in Directory.GetFiles(FullPath))
{
RemoveSpywareFile(FileName);
}
if (Recursive)
{
foreach (string DirName in Directory.GetDirectories(FullPath))
{
RemoveSpywareFiles("", DirName, true);
try { Directory.Delete(DirName); }catch { }
}
}
DInfo.Attributes = Attr;
}
}
private static void RemoveSpywareFile(string FileName)
{
if (File.Exists(FileName))
{
try { File.Delete(FileName); }catch { }//Locked by something and you can forget trying to delete index.dat files this way
}
}
private static void DeleteFireFoxFiles(string FireFoxPath)
{
RemoveSpywareFile(FireFoxPath + "cookies.sqlite");
RemoveSpywareFile(FireFoxPath + "content-prefs.sqlite");
RemoveSpywareFile(FireFoxPath + "downloads.sqlite");
RemoveSpywareFile(FireFoxPath + "formhistory.sqlite");
RemoveSpywareFile(FireFoxPath + "search.sqlite");
RemoveSpywareFile(FireFoxPath + "signons.sqlite");
RemoveSpywareFile(FireFoxPath + "search.json");
RemoveSpywareFile(FireFoxPath + "permissions.sqlite");
}
public static void RunCleanup()
{
try { KillProcess("iexplore"); }
catch { }//Need to stop incase they have locked the files we want to delete
try { KillProcess("FireFox"); }
catch { }//Need to stop incase they have locked the files we want to delete
string RootPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal).ToLower().Replace("documents", "");
RemoveSpywareFiles(RootPath, @"AppData\Roaming\Macromedia\Flash Player\#SharedObjects",false);
RemoveSpywareFiles(RootPath, @"AppData\Roaming\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\#local", false);
RemoveSpywareFiles(RootPath, @"AppData\Local\Temporary Internet Files", false);//Not working
RemoveSpywareFiles("", Environment.GetFolderPath(Environment.SpecialFolder.Cookies), true);
RemoveSpywareFiles("", Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), true);
RemoveSpywareFiles("", Environment.GetFolderPath(Environment.SpecialFolder.History), true);
RemoveSpywareFiles(RootPath, @"AppData\Local\Microsoft\Windows\Wer", true);
RemoveSpywareFiles(RootPath, @"AppData\Local\Microsoft\Windows\Caches", false);
RemoveSpywareFiles(RootPath, @"AppData\Local\Microsoft\WebsiteCache", false);
RemoveSpywareFiles(RootPath, @"AppData\Local\Temp", false);
RemoveSpywareFiles(RootPath, @"AppData\LocalLow\Microsoft\CryptnetUrlCache", false);
RemoveSpywareFiles(RootPath, @"AppData\LocalLow\Apple Computer\QuickTime\downloads", false);
RemoveSpywareFiles(RootPath, @"AppData\Local\Mozilla\Firefox\Profiles", false);
RemoveSpywareFiles(RootPath, @"AppData\Roaming\Microsoft\Office\Recent", false);
RemoveSpywareFiles(RootPath, @"AppData\Roaming\Adobe\Flash Player\AssetCache", false);
if (Directory.Exists(RootPath + @"\AppData\Roaming\Mozilla\Firefox\Profiles"))
{
string FireFoxPath = RootPath + @"AppData\Roaming\Mozilla\Firefox\Profiles\";
DeleteFireFoxFiles(FireFoxPath);
foreach (string SubPath in Directory.GetDirectories(FireFoxPath))
{
DeleteFireFoxFiles(SubPath + "\\");
}
}
}
private static void KillProcess(string ProcessName)
{//We ned to kill Internet explorer and Firefox to stop them locking files
ProcessName = ProcessName.ToLower();
foreach (Process P in Process.GetProcesses())
{
if (P.ProcessName.ToLower().StartsWith(ProcessName))
P.Kill();
}
}
}
}
I'll give you a hand on this..
this is what i use myself.
i summon a prompt box, edit it as you wish
@echo off
echo.
echo Clearing History
echo Please close this window if opening this was a mistake.
pause
echo.
echo Clearing History: File Explorer
Del /F /Q %APPDATA%\Microsoft\Windows\Recent\*
Del /F /Q %APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations\*
Del /F /Q %APPDATA%\Microsoft\Windows\Recent\CustomDestinations\*
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /VA /F
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths /VA /F
echo.
echo Completed!
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Clearing History: Firefox
echo.
echo Scanning for 'Firefox' data
set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles
IF NOT EXIST "%DataDir%" GOTO NOFIREFOXDIR
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
GOTO YESFIREFOXDIR
:NOFIREFOXDIR
echo.
echo Firefox NOT found!
echo.
GOTO CHROMESETUP
:YESFIREFOXDIR
echo.
echo Completed!
echo.
:CHROMESETUP
echo -----------------------------------------------------------------------------------
echo.
echo Clearing History: Google Chrome
echo.
echo Scanning for 'Google Chrome' data.
set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data
IF NOT EXIST "%ChromeDir%" GOTO NOCHROMEDIR
del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"
GOTO YESCHROMEDIR
:NOCHROMEDIR
echo.
echo Google Chrome NOT found!
echo.
GOTO OPERASETUP
:YESCHROMEDIR
echo.
echo Completed!
echo.
:OPERASETUP
echo -----------------------------------------------------------------------------------
echo.
echo Clearing History: Opera
echo.
echo Scanning for 'Opera' data.
set OperaDir=C:\Users\%USERNAME%\AppData\Local\Opera\Opera
set OperaDir2=C:\Users\%USERNAME%\AppData\Roaming\Opera\Opera
IF NOT EXIST "%OperaDir%" GOTO OPERA2
del /q /s /f "%Opera%"
rd /s /q "%Opera%"
:OPERA2
IF NOT EXIST "%OperaDir2%" GOTO NOOPERADIR
del /q /s /f "%Opera2%"
rd /s /q "%Opera2%"
GOTO YESOPERADIR
:NOOPERADIR
echo.
echo Opera NOT found!
echo.
GOTO APPLESETUP
:YESOPERADIR
echo.
echo Completed!
echo.
:APPLESETUP
echo -----------------------------------------------------------------------------------
echo.
echo Clearing History: Apple Safari
echo.
echo Scanning for 'Apple Safari' data.
set AppleDir=C:\Users\%USERNAME%\AppData\Local\Applec~1\Safari
set AppleDir2=C:\Users\%USERNAME%\AppData\Roaming\Applec~1\Safari
IF NOT EXIST "%AppleDir%" GOTO APPLESETOP
del /q /s /f "%AppleDir%\History"
rd /s /q "%AppleDir%\History"
del /q /s /f "%AppleDir%\Cache.db"
del /q /s /f "%AppleDir%\WebpageIcons.db"
:APPLESETOP
IF NOT EXIST "%AppleDir2%" GOTO NOAPPLEDIR
del /q /s /f "%AppleDir2%"
rd /s /q "%AppleDir2%"
GOTO YESAPPLEDIR
:NOAPPLEDIR
echo.
echo Apple Safari NOT found!
echo.
GOTO INTESETUP
:YESAPPLEDIR
echo.
echo Completed!
echo.
:INTESETUP
echo -----------------------------------------------------------------------------------
echo.
echo Clearing History: Microsoft Internet Explorer
echo.
echo Scanning for 'Microsoft Internet Explorer' data.
set IEDataDir=C:\Users\%USERNAME%\AppData\Local\Microsoft\Intern~1
IF NOT EXIST "%IEDataDir%" GOTO HISTORYDIR
del /q /s /f "%IEDataDir%"
rd /s /q "%IEDataDir%"
:HISTORYDIR
set History=C:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\History
IF NOT EXIST "%History%" GOTO IETEMPDIR
del /q /s /f "%History%"
rd /s /q "%History%"
:IETEMPDIR
set IETemp=C:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\Tempor~1
IF NOT EXIST "%History%" GOTO COOKIESDIR
del /q /s /f "%IETemp%"
rd /s /q "%IETemp%"
:COOKIESDIR
set Cookies=C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Cookies
IF NOT EXIST "%Cookies%" GOTO FLASHCCC
del /q /s /f "%Cookies%"
rd /s /q "%Cookies%"
:FLASHCCC
set FlashCookies=C:\Users\%USERNAME%\AppData\Roaming\Macromedia\Flashp~1
IF NOT EXIST "%FlashCookies%" GOTO FINAL
del /q /s /f "%FlashCookies%"
rd /s /q "%FlashCookies%"
:FINAL
echo.
cls
echo.
echo Thank you for using our cleaner...
echo.
pause