[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] VBS如何实现重建图标缓存?

本帖最后由 pcl_test 于 2016-1-1 18:03 编辑

本人已经搜索过,“缓存”,并没有。(实在是害怕某人又说我抄作什么)。

百度搜索的代码据说很旧,win98时代的:
  1. On Error Resume Next
  2. If MsgBox("将关闭所有打开的资源管理器窗口,并重建图标缓存。" & vbCrLf & "是否继续?",vbYesNo+vbQuestion,"询问")= vbNo Then
  3. Wscript.Quit
  4. End If
  5. Set FSO = CreateObject("Scripting.FileSystemObject")
  6. FSO.DeleteFile(FSO.GetSpecialFolder(0) & "\shelliconcache")
  7. Set FSO = Nothing
  8. Set Pros = GetObject("winmgmts:\\.\root\cimv2").ExecQuery ("Select * from Win32_Process Where Name = 'explorer.exe'")
  9. For Each Pro in Pros
  10. Pro.Terminate
  11. Next
  12. Set Pros = Nothing
  13. MsgBox "操作已完成。",vbInformation,"提示"
复制代码
去除On Error Resume Next后,果然说找不到目录。

回复 6# ygqiang

看样子是全删,那么何不
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db"

TOP

回复 3# Heykuz
  1. rem 关闭Windows外壳程序explorer  
  2.   taskkill /f /im explorer.exe  
  3.   rem 清理系统图标缓存数据库  
  4.   attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db"  
  5.   del /f "%userprofile%\AppData\Local\IconCache.db"  
  6.   attrib /s /d -h -s -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*"
  7. del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db"
  8.   del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db"
  9.   del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_102.db"
  10.   del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db"
  11.   del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db"
  12.   del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db"
  13.   del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db"
  14.   rem 清理 系统托盘记忆的图标  
  15.   echo y reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v IconStreams
  16.   echo y reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v PastIconsStream  
  17.   rem 重启Windows外壳程序explorer  
  18. rem start explorer
复制代码

TOP

回复 3# Heykuz


    重建图标缓存,啥时候有用呢?

TOP

回复 3# Heykuz
  1. 'Wscript.Echo "Successfully refreshed icon cache."
  2. 'objWshShell.Run "explorer.exe"
复制代码

TOP

删掉每个目录下的 Thumbs.db
CrLf 发表于 2015-12-30 14:59


大神,下面一段是我在外国网站下载的,测试通过,可以重建图标缓存。但是有一个要求确定的msgbox,不知道如何去除。请大神帮忙修改。
  1. Option Explicit
  2. Dim objWMIService, objProcess, colProcess
  3. Dim strComputer, strProcessName
  4. strComputer = "."
  5. strProcessName = "'explorer.exe'"
  6. Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  7. Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & strProcessName )
  8. For Each objProcess in colProcess
  9. objProcess.Terminate()
  10. Next
  11. Dim objWshShell
  12. Set objWshShell = WScript.CreateObject("WScript.Shell")
  13. objWshShell.Run "ie4uinit.exe -cleariconcache"
  14. Wscript.Echo "Successfully refreshed icon cache."
  15. objWshShell.Run "explorer.exe"
  16. Wscript.Quit
复制代码

TOP

删掉每个目录下的 Thumbs.db

TOP

返回列表