here is the code. If you run it, it will stop running when it encounters
longer name of a folder which has many spaces between words.
i hope you can fix this problem. Thanks
'============
strDir = “c:\windowsâ€
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Call EnumAll(strDir)
'====sub below=======
sub EnumAll(fldr)
Set FileList = objWMIService.ExecQuery("ASSOCIATORS OF
{Win32_Directory.Name='"&fldr&"'}" & " Where ResultClass = CIM_DataFile ")
For Each objFile In FileList
wscript.echo("File: "&objFile.Name)
Next
set Folders=objWMIService.ExecQuery("ASSOCIATORS of
{Win32_Directory.Name='"&fldr&"'}" & " where AssocClass = Win32_Subdirectory
ResultRole = PartComponent")
For each folder in Folders
wscript.echo(vbcrlf&"Folder: "&folder.Name)
Call EnumAll(folder.Name) 'recursion. Go through everything
next
end sub