Folks...I need a script to delete all "New Folders" on the c drive..no matter where it exists....New Folder..New Folder(1)..New Folder(2)....OR..
C:\data\files\New Folder\papers\New Folder....etc.
I want this to search through all sub-directories too..currently what I have searches only the c:\ and not the sub-directories...
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name Like '%c:\\New Folder%'")
For Each objFolder in colFolders
objFolder.delete
Next
C:\data\files\New Folder\papers\New Folder....etc.
I want this to search through all sub-directories too..currently what I have searches only the c:\ and not the sub-directories...
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name Like '%c:\\New Folder%'")
For Each objFolder in colFolders
objFolder.delete
Next