Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

long running query

Status
Not open for further replies.

scrsadmin

Technical User
May 3, 2004
62
US
I'm trying to search for subfolders that start with the letter R in a C:\Program Files\iafolder\TempFiles and then delete only the one found. I created this but it seems to run long. It finds three, deletes three and then i get an hour glass for about 5 more minutes before it goes to the next step. Any ideas?

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name Like '%C:\\Program Files\\iafolder\\TempFiles\\r%'")
For Each objFolder in colFolders
WScript.Echo "Name: " & objFolder.Name
objFSO.DeleteFolder objFolder.Name
WScript.Echo "Name: " & objFolder.Name
Next
 
Can't you just use
Code:
Dim fso
set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder "C:\Program Files\iafolder\TempFiles\r*"
 
I did the fso.DeleteFolder "C:\Program Files\iafolder\TempFiles\r*" but if there is no folder with that criteria then I get a big fat error splashed on the screen. I don't want the user to know that we are doing anything. So by doing it the way I set up it finds them if the folder exists and then deletes them. End result no error splashed on the screen if the folder doesn't exist.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top