代码之家  ›  专栏  ›  技术社区  ›  user46795

使用脚本清除Internet Explorer 6.0浏览历史记录

  •  4
  • user46795  · 技术社区  · 17 年前

    我使用以下脚本删除IE 7.0中的浏览历史记录

    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
    

    但是现在我需要一个脚本来清除IE 6.0中的浏览历史记录

    我得到一个错误,“缺少条目ClearMyTracksByProcess”,我传递了不同的参数,如2、5等,但没有成功。

    5 回复  |  直到 12 年前
        1
  •  3
  •   user48307    17 年前
    // 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;
    }
    
        2
  •  2
  •   VonC    17 年前

    自从 INETCPL.CPL version 7.0 ClearMyTracksByProcessW ,它可能不存在于IE6中。

    因此,脚本可能是更基本的解决方案:

    @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 
    

    (您只能保留对此脚本感兴趣的“删除”)

    但是, reported in this thread


    唯一的其他解决方案是使用(免费)第三方实用程序:

    alt text http://www.ccleanerbeginnersguide.com/ccleanerhelp.png CCleaner

    其他选择包括 mentionned in this thread :

        3
  •  0
  •   i_am_jorf    17 年前

    ClearMyTracks()不是IE6的一部分,因此不能使用相同的技巧。

    如果您只想清除历史记录,可以编写一个小程序,只需共同创建(CLSID_CUrlHistory,IID_IUrlHistoryStg2),然后调用 IUrlHistoryStg::ClearHistory() .

    应该能够从VBScript也这样做,但我不知道正确的魔咒。

        4
  •  0
  •   Flash    14 年前

    坏消息

    在Win 7和IE8/9上尝试使用ClearMyTracksByProcess删除internet历史不再有效,您只能在启动时运行dos delete命令来清理部分文件,因为microsoft使用超级隐藏文件夹、锁定文件,这会造成一团混乱,并使big Brother感到不安。

    此代码清除IE8/9 plus FireFox和共享对象/flash Cookie,但如果要删除Index.dat文件,请单击“我的名字”查看代码。

    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();
                }
            }
        }
    }
    
        5
  •  0
  •   Michael Bakker    9 年前

    我会帮你的。。

    我调用一个提示框,按您的意愿编辑它

    @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