Function Del_CookieCache()
'设置Dictionary用于存储返回的三个字符串
Dim obj_Dictionary,a,b,c
Set obj_Dictionary = CreateObject ("Scripting.Dictionary")
'获取当前操作系统
Dim wmiService,wmiObjects,wmiObject
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each wmiObject In wmiObjects
str_Systype = wmiObject.Caption
next
str_Systype = Trim(str_Systype)
MsgBox ("操作系统类型:"&str_Systype)
'根据操作系统类型设置cookie与cache在注册表的位置
Dim str_cookiePath_forWin7,str_CachePath_forWin7
Dim str_cookiePath_forWinXP,str_CachePath_forWinXP
Dim str_CookiePath,str_CachePath
Dim objWshShell,objWshShell_P
Dim error_code
error_code =0
' For i = 0 To 2 Step 1
' MsgBox obj_Dictionary.Item(i)
' Next
End Function
Function del_exc()
Dim objTmp_Dictionary,dicArray,fso
'定义要删除的cookie类型
cookie_type = "\*paipai*"
Set objTmp_Dictionary = Del_CookieCache
dicArray = objTmp_Dictionary.Items
MsgBox dicArray(0)
If trim(dicArray(0)) = "1" Then
MsgBox "当前操作系统未添加"
Exit Function
Else If trim(dicArray(0)) = "0" Then
Set fso = CreateObject("Scripting.filesystemobject")
If (fso.folderexists(dicArray(1))) Then
dicArray(1) = dicArray(1) +"\*.*"
fso.deletefile(dicArray(1))
MsgBox "cookie删除成功"
End If
If (fso.folderexists(dicArray(2))) Then
dicArray(2) = dicArray(2) +"\*.*"
fso.deletefile(dicArray(2))
MsgBox "删除cache成功"
End If
'MsgBox ("error_code:"&a(0)&vbLf& _
' "str_CookiePath:"&vbLf&a(1)&vbLf& _
' "str_CachePath:"&vbLf&a(2))
End If
End If
End Function
Call del_exc()作者: zk_testing 时间: 2011-7-8 17:48
我自己搞定了。。
还能进一步优化一下。下面是代码。
'设置Dictionary用于存储返回的三个字符串
Dim obj_Dictionary,a,b,c
Set obj_Dictionary = CreateObject ("Scripting.Dictionary")
'获取当前操作系统
Dim wmiService,wmiObjects,wmiObject
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each wmiObject In wmiObjects
str_Systype = wmiObject.Caption
next
str_Systype = Trim(str_Systype)
' MsgBox ("操作系统类型:"&str_Systype)
'根据操作系统类型设置cookie与cache在注册表的位置
Dim str_cookiePath_forWin7,str_CachePath_forWin7
Dim str_cookiePath_forWinXP,str_CachePath_forWinXP
Dim str_CookiePath,str_CachePath
Dim objWshShell,objWshShell_P
Dim error_code
error_code = 0
If error_code = "1" Then
MsgBox "当前操作系统未添加"
Exit Function
ElseIf error_code = "0" Then
Set wsh = CreateObject("Wscript.shell")
wsh.Run "%comspec% /C del /F /Q "&cookie_path&"\*.*"
wsh.Run "%comspec% /C del /F /Q "&cache_path&"\*.*"
End If