I use the following script to find folders with a specific name on my PC. However this script searches the whole computer every time. I am quite new to regular expressions. I'd like to modify the script in a way it limits the search to a folder, lets say: c:\temp
I understand the code except the bold lines, maybe someone could explain these lines in plain language... and point me in the direction for finding the solution.
I understand the code except the bold lines, maybe someone could explain these lines in plain language... and point me in the direction for finding the solution.
Code:
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = "ABCD"
[b]
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery("Select * From Win32_Directory")
[/b]
For Each objFolder in colFolders
strFolder = objFolder.FileName
Set colMatches = objRegEx.Execute(strFolder)
If colMatches.Count > 0 Then
Wscript.Echo objFolder.Name
End If
Next