'刪除目錄下的所有文件及文件夾
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("所有操作已成功執(zhí)行!")
else
end if
這個就比較智能了,通過winmgmts獲取系統(tǒng)中的網卡列表,然后遍歷啟用的網卡,然后進行修改。而臨時文件部分,也是通過讀取注冊表“HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folderscache”項的鍵值來獲取文件夾位置。之后通過創(chuàng)建的fso對象的相應方法給他干掉~