Just two simple examples:
1. Delete a File:
Enter the path to your file here:
file = "C:\Users\Vadim\AppData\Local\Stardock\SD Gadgets\RSS Reader\Feeds\N4G.com"
Set objWMI = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set objFIL = objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"& file &"'} Where "&"ResultClass = CIM_DataFile")
For Each item In objFIL
item.Delete
Next
Set objFIL = nothing : Set objWMI = nothing
1. Delete a Folder:
Enter the path to your folder here:
folder = "C:\Users\Vadim\AppData\Local\Stardock\SD Gadgets\RSS Reader\Feeds"
folder = Replace(folder, "\", "\\") '<== it's need to replace the path to foler...
Set objWMI = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set objFOL = objWMI.ExecQuery ("Select * from Win32_Directory where Name = '" & folder & "'")
For Each item In objFOL
item.Delete
Next
Set objFOL = nothing : Set objWMI = nothing
Long ago I have used FSO for this. But it seems to me that WMI work more quickly.
Best Regards.