标题: [问题求助] VBS如何实现重建图标缓存? [打印本页]
作者: Heykuz 时间: 2015-12-30 12:04 标题: VBS如何实现重建图标缓存?
本帖最后由 pcl_test 于 2016-1-1 18:03 编辑
本人已经搜索过,“缓存”,并没有。(实在是害怕某人又说我抄作什么)。
百度搜索的代码据说很旧,win98时代的:- On Error Resume Next
- If MsgBox("将关闭所有打开的资源管理器窗口,并重建图标缓存。" & vbCrLf & "是否继续?",vbYesNo+vbQuestion,"询问")= vbNo Then
- Wscript.Quit
- End If
- Set FSO = CreateObject("Scripting.FileSystemObject")
- FSO.DeleteFile(FSO.GetSpecialFolder(0) & "\shelliconcache")
- Set FSO = Nothing
- Set Pros = GetObject("winmgmts:\\.\root\cimv2").ExecQuery ("Select * from Win32_Process Where Name = 'explorer.exe'")
- For Each Pro in Pros
- Pro.Terminate
- Next
- Set Pros = Nothing
- MsgBox "操作已完成。",vbInformation,"提示"
复制代码
去除On Error Resume Next后,果然说找不到目录。
作者: CrLf 时间: 2015-12-30 14:59
删掉每个目录下的 Thumbs.db
作者: Heykuz 时间: 2016-1-1 16:22
删掉每个目录下的 Thumbs.db
CrLf 发表于 2015-12-30 14:59
大神,下面一段是我在外国网站下载的,测试通过,可以重建图标缓存。但是有一个要求确定的msgbox,不知道如何去除。请大神帮忙修改。- Option Explicit
- Dim objWMIService, objProcess, colProcess
- Dim strComputer, strProcessName
-
- strComputer = "."
- strProcessName = "'explorer.exe'"
-
- Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
- Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & strProcessName )
-
- For Each objProcess in colProcess
- objProcess.Terminate()
- Next
-
- Dim objWshShell
- Set objWshShell = WScript.CreateObject("WScript.Shell")
-
- objWshShell.Run "ie4uinit.exe -cleariconcache"
- Wscript.Echo "Successfully refreshed icon cache."
-
- objWshShell.Run "explorer.exe"
- Wscript.Quit
复制代码
作者: ygqiang 时间: 2016-1-1 17:16
回复 3# Heykuz - 'Wscript.Echo "Successfully refreshed icon cache."
- 'objWshShell.Run "explorer.exe"
复制代码
作者: ygqiang 时间: 2016-1-1 17:18
回复 3# Heykuz
重建图标缓存,啥时候有用呢?
作者: ygqiang 时间: 2016-1-1 17:24
回复 3# Heykuz - rem 关闭Windows外壳程序explorer
- taskkill /f /im explorer.exe
- rem 清理系统图标缓存数据库
- attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db"
- del /f "%userprofile%\AppData\Local\IconCache.db"
- attrib /s /d -h -s -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*"
- del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db"
- del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db"
- del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_102.db"
- del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db"
- del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db"
- del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db"
- del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db"
- rem 清理 系统托盘记忆的图标
- echo y reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v IconStreams
- echo y reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v PastIconsStream
- rem 重启Windows外壳程序explorer
- rem start explorer
复制代码
作者: pcl_test 时间: 2016-1-1 17:44
回复 6# ygqiang
看样子是全删,那么何不
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db"
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |