To use a folder path that contains legal special characters in Visual Basic, enclose the folder path in double quotes ("), escaping every occurrence of a backslash (\).

I have scripted enumFolderPath.vbs to accept a folder path, properly encapsulate it, escaping all backslash characters, and enumerate its' sub-folders.

The syntax for using enumFolderPath.vbs is:

<b>cscript //nologo c:\folder\enumFolderPath.vbs Folder</b>Where Folder is the folder path, like c:\file's or "C:\Documents and Settings\Jerry\My Documents\My script's".

enumFolderPath.vbs contains:

Dim objArgs
Set objArgs = Wscript.Arguments
if objArgs.Count  1 then
 Wscript.Echo  "Folder PATH required."
 WScript.Quit (1)
End If
Fldr = Replace(objArgs(0), "\", "\\")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "\{impersonationLevel=impersonate\}!\\" & strComputer & "\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery _
 ("ASSOCIATORS OF \{Win32_Directory.Name=<div class="Contentquote"><center> & Fldr &</center></div>\} " _
 & "WHERE AssocClass = Win32_Subdirectory " _
 & "ResultRole = PartComponent")
For Each objFolder in colSubfolders
 Wscript.Echo objFolder.Name