Http 以编程方式清除Windows 7上Internet Explorer 8中的缓存
我正在写一个脚本来测试我们的互联网性能。基本上,它打开IE,浏览一个网站(比如yahoo.com),退出IE,清除缓存,然后重复 我遇到的问题是IE缓存没有被完全清除。我之所以知道这一点,是因为我们查看了一些数据包,发现许多针对网页对象的HTTP请求返回304,这意味着缓存没有被清除 我尝试了两个选项,手动清除临时文件夹和使用命令Http 以编程方式清除Windows 7上Internet Explorer 8中的缓存,http,caching,batch-file,Http,Caching,Batch File,我正在写一个脚本来测试我们的互联网性能。基本上,它打开IE,浏览一个网站(比如yahoo.com),退出IE,清除缓存,然后重复 我遇到的问题是IE缓存没有被完全清除。我之所以知道这一点,是因为我们查看了一些数据包,发现许多针对网页对象的HTTP请求返回304,这意味着缓存没有被清除 我尝试了两个选项,手动清除临时文件夹和使用命令 RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 但两者似乎都没有完全清除缓存。有更好的方法吗?Intern
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
但两者似乎都没有完全清除缓存。有更好的方法吗?Internet Explorer更狡猾。它将历史记录、cookies和缓存存储在所有地方,包括注册表 我认为下面的方法适用于您,因为它删除了所有位置的所有数据:
@echo off
set DataDir=C:\Users\%USERNAME%\AppData\Local\Microsoft\Intern~1
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
set History=C:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\History
del /q /s /f "%History%"
rd /s /q "%History%"
set IETemp=C:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\Tempor~1
del /q /s /f "%IETemp%"
rd /s /q "%IETemp%"
set Cookies=C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Cookies
del /q /s /f "%Cookies%"
rd /s /q "%Cookies%"
或者,如果还希望从注册表中删除数据,可以在上面添加以下步骤:
C:\bin\regdelete.exe HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\TypedURLs"
请注意,最后一个命令是regdelete.exe。它是一个小型的Win32工具,用C++编写,它清除了IE历史,因为它将它存储在注册表中。
以下是regdelete.c程序:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
// compile as: mingw32-g++ regdelete.c -o regdelete.exe -mwindows
#define eq(s1,s2) (strcmp((s1),(s2))==0)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow)
{
if (!cmdLine || !strlen(cmdLine)) {
printf("Usage: regdel.exe <HKEY> <path to regkey> - be careful not to delete whole registry\n");
return 1;
}
int argc;
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argc < 3) {
printf("Usage: regdel.exe <HKEY> <path to regkey> - be careful not to delete whole registry\n");
return 1;
}
char **argv8 = (char **)malloc(sizeof(char *) * argc);
for (int i = 0; i<argc; i++) {
int len = wcslen(argv[i]);
argv8[i] = (char *)malloc(sizeof(char)*(len+1));
wcstombs(argv8[i], argv[i], len+1);
}
HKEY hkey;
if (eq(argv8[1], "HKEY_CLASSES_ROOT")) {
hkey == HKEY_CLASSES_ROOT;
}
else if (eq(argv8[1], "HKEY_CURRENT_CONFIG")) {
hkey = HKEY_CURRENT_CONFIG;
}
else if (eq(argv8[1], "HKEY_CURRENT_USER")) {
hkey = HKEY_CURRENT_USER;
}
else if (eq(argv8[1], "HKEY_LOCAL_MACHINE")) {
hkey = HKEY_LOCAL_MACHINE;
}
else if (eq(argv8[1], "HKEY_USERS")) {
hkey = HKEY_USERS;
}
else {
printf("Unknown hkey\n");
return 1;
}
HKEY key;
int status = RegOpenKeyEx(hkey, argv8[2], 0, KEY_ALL_ACCESS, &key);
if (status != ERROR_SUCCESS) {
printf("failed opening %s\n", argv8[2]);
return 1;
}
std::vector<std::string> vals;
for (unsigned int i = 0; ; i++) {
DWORD size = 1024;
char val[size+1];
DWORD type;
status = RegEnumValue(key, i, val, &size, NULL, &type, NULL, NULL);
if (status == ERROR_NO_MORE_ITEMS) break;
if (status == ERROR_SUCCESS) {
vals.push_back(std::string(val));
continue;
}
printf("failed enumerating %s\n", argv8[2]);
return 1;
}
typedef std::vector<std::string>::iterator vsi;
for (vsi i = vals.begin(); i != vals.end(); i++) {
status = RegDeleteValue(key, i->c_str());
if (status != ERROR_SUCCESS) {
printf("failed deleting %s\n", i->c_str());
return 1;
}
}
return 0;
}
#包括
#包括
#包括
#包括
#包括
//编译为:mingw32-g++regdelete.c-o regdelete.exe-mwindows
#定义等式(s1,s2)(strcmp((s1),(s2))==0)
int WinMain(HINSTANCE HINSTANCE、HINSTANCE hPrevInstance、LPSTR cmdLine、int nCmdShow)
{
如果(!cmdLine | |!strlen(cmdLine)){
printf(“用法:regdel.exe-小心不要删除整个注册表\n”);
返回1;
}
int-argc;
LPWSTR*argv=CommandLineToArgvW(GetCommandLineW(),&argc);
如果(argc<3){
printf(“用法:regdel.exe-小心不要删除整个注册表\n”);
返回1;
}
char**argv8=(char**)malloc(sizeof(char*)*argc);
对于(int i=0;ic_str());
如果(状态!=错误\u成功){
printf(“删除%s\n失败”,i->c_str());
返回1;
}
}
返回0;
}
只需编译上述程序,您就可以在批处理中使用此regdelete.exe。尝试删除“..\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5”中的所有内容`