Thứ Ba, 16 tháng 6, 2009

Dọn dẹp Cache trong Google Chrome bằng Script

Mình có 1 mẹo nhỏ làm sạch sẽ Cache, giúp những ai thường xuyên sử dụng Chrome mà không để ý đến Cache của nó. Ứng dụng này được chạy bằng Script được thử nghiệm trên phiên bản Chrome 1.0.154.36, được thực hiện trên Win XP và Vista.
Trước hết bạn copy đoạn code này vào Notepad và lưu lại với các tên DelChromeCache.vbs

'Script to clear Google Chrome browser cache
'Tested with Google Chrome 1.0.154.36 ...
'-------------------------------------------------
intClearPasswords = 1
intShowMessageBox = 0
'-------------------------------------------------
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
intDirtyFlags = 0
strMsg = "Google Chrome cache is cleared!" & vbcrlf & vbcrlf & _
"@ 2009 by doanngocthinh. The ngocthinhpro Blogspot" & vbcrlf & _
"http://ngocthinhpro.blogspot.com"

strMsg2 = "Google Chrome cache could not be cleared!"

If GetOS = "Vista" Then
strCacheLoc = WshShell.ExpandEnvironmentStrings("%LocalAppData%") & _
"\Google\Chrome\User Data\Default"
Else
strCacheLoc = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") & _
"\Local Settings\Application Data\Google\Chrome\User Data\Default"
End If

If objFSO.FolderExists(strCacheLoc) then
Set objFolder = objFSO.GetFolder(strCacheLoc)
Set colFiles = objFolder.Files
For Each objFile in colFiles
On Error Resume Next
If intClearPasswords = 0 then
If objFile.Name <> "Cookies" And objFile.Name <> "Bookmarks" And objFile.Name <> "Preferences" And objFile.Name <> "Web Data" then objFSO.DeleteFile(objFile)
else
If objFile.Name <> "Preferences" And objFile.Name <> "Bookmarks" Then objFSO.DeleteFile(objFile)
End If

If err.number <> 0 then intDirtyFlags = 1
Err.clear
On Error Goto 0
Next
On Error Resume Next
If objFSO.FolderExists(strCacheLoc & "\cache") then objFSO.deletefolder(strCacheLoc & "\cache")
If err.number <> 0 then intDirtyFlags = 1
On Error Goto 0

If intDirtyFlags = 1 then
If intShowMessageBox = 1 then Msgbox strMsg2
else
If intShowMessageBox = 1 then Msgbox strMsg
end if
End If

Function GetOS
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
osCaption = objOS.Caption
If instr(osCaption, "Vista") Then
GetOS = "Vista"
End If
Next
End Function


Sau đó bạn chạy file này, đặc biệt file này chạy ở chế độ ẩn nên bạn không nhìn thấy được. Nó sẽ dọn sạch Cache, Cookie và pass lưu trữ trong Chrome. Dưới đây là ảnh minh họa mà mình đặt nó chạy không nằm ở chế độ ẩn


Trấn Phiên

Không có nhận xét nào:

Đăng nhận xét

Thank! mong cần có thêm nhiều ý kiến nữa