第一个是用bat批处理命令,可以正常执行
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 start explorer
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,"提示"
现在知道出现上面的错误的原因了,谢谢tea_pig!
把程序的第二句话修改为下面就可以了,多了个下划线!
If MsgBox("将关闭所有打开的资源管理器窗口,并重建图标缓存。" & vbCrLf & "是否继续?",vbYesNo+vbQuestion,"询问")= vbNo Then