Can you use the "Like" option as in the next code ?
' Returns a list of all the folders whose path begins with C:\S. This script runs only under Windows XP or Windows .NET Server.
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFolders = objWMIService.ExecQuery _ ("Select * from Win32_Directory where Name Like '%c:\\S%'") For Each objFolder in colFolders Wscript.Echo "Name: " & objFolder.Name Next
Maybe you can play with this option to see how it works. Good luck !
< Message edited by didorno -- 7/20/2005 6:52:23 AM >
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFolders = objWMIService.ExecQuery (" Select * from Win32_Directory where Name Like '%d:\\" + search + "%' ")
For Each objFolder in colFolders
'Enable Error Handling On Error Resume Next
if instr(4, objFolder.Name, "\") < 3 then Wscript.Echo "Name: " & objFolder.Name + " folder found" found = true end if
Next
If the search finds no matches I want to throw up a message box saying "Not found" But it doesn't work if add another if statements. Any help?
quote:Originally posted by snanuwa .............. if instr(4, objFolder.Name, "\") < 3 then Wscript.Echo "Name: " & objFolder.Name + " folder found" found = true end if ..............
The condition in the If statement above becomes only True if "\" is not present at or after the 4th position. But then you can compare with 0 and do not need the value 3. Is that what you want ?
Can you give a few examples of acceptable and non-acceptable folders ? Then better help is possible.
quote: ................ If the search finds no matches I want to throw up a message box saying "Not found" But it doesn't work if add another if statements. Any help?
Thanks
Do you mean the use of
If expression = true Then Do1 Else WScript.Echo "Folder NOT found" End If