'删除目录下的所有文件及文件夹
Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(net_temp"*.*"), DeleteReadOnly
strComputer = "."
Set objWMIService = GetObject("winmgmts:" strComputer "rootcimv2")
Set colSubfolders2 = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" net_temp "'} " _
"Where AssocClass = Win32_Subdirectory " _
"ResultRole = PartComponent")
For Each objFolder2 in colSubfolders2
objFSO.deleteFolder objFolder2.name , DeleteReadOnly
Next
MsgBox("所有操作已成功执行!")
else
end if
这个就比较智能了,通过winmgmts获取系统中的网卡列表,然后遍历启用的网卡,然后进行修改。而临时文件部分,也是通过读取注册表“HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folderscache”项的键值来获取文件夹位置。之后通过创建的fso对象的相应方法给他干掉~