I am fighting what should be simple VBScript function here. The goal of my script is to take 2 input values and find the matching subfolder. I then want the function to return the path to that folder. Below is what I have, but am having trouble making it return the value. It doesn't seem to be exiting the function and returning the value.
Here is what I have so far.
Function GetFolderName(folderspec,Computer)
WScript.Echo "checking: " & folderspec
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(folderspec)
If UCase(objFolder.Name) = UCase(Computer) Then
GetFolderName = folderspec
Exit Function
End If
Set arrSubfolders = objFolder.SubFolders
For Each f1 in arrSubfolders
folderspec = GetFolderName(f1.Path,Computer)
Next
End Function
strFolder = GetFolderName("C:\Test","Trial3")