I would change that code to something such as:
Query = "Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent"
MsgBox Query
Set colSubfolders = objWMIService.ExecQuery(Query)
So I could see what I actually get. I could see if the escaped characters
are processed as I assume they would be.
My guess is that you are confusing JavaScript with VBScript. I do not
remember if WMI uses the backslash as an escape character but VBScript does
not.
<bryons@gmail.com> wrote in message
news:1189528262.595513.271600@r29g2000hsg.googlegr oups.com...
>I am trying to fix some code that MS released to recursively list
> files in folders (http://www.microsoft.com/technet/scriptcenter/
> resources/qanda/feb05/hey0218.mspx) so that it handles ' and } when
> they are in the paths. I have been successful with the } but the ' is
> giving me fits! Here's the offending line:
>
> Set colSubfolders2 = objWMIService.ExecQuery _
> ("Associators of {Win32_Directory.Name='" & strFolderName &
> "'} " _
> & "Where AssocClass = Win32_Subdirectory " _
> & "ResultRole = PartComponent")
>
> When the query is:
> Associators of {Win32_Directory.Name='d:\\inetpub\\content\\india
> photos\\john'} Where AssocClass = Win32_Subdirectory ResultRole =
> PartComponent
> Everything works fine.
>
> When I try to escape the ' in mike's pix I get the error below
> Associators of {Win32_Directory.Name='d:\\inetpub\\content\\india
> photos\\mike\'s pix'} Where AssocClass = Win32_Subdirectory ResultRole
> = PartComponent
> C:\Temp\test2.vbs(46, 5) (null): 0x8004103A
>
> Am I not escaping the ' correctly?
>