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?
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.
<bry...@gmail.com> wrote in message
news:1189528262.5...@r29g2000hsg.googlegroups.com...
I found someone else with the same problem:
http://www.scriptinganswers.com/forum2/forum_posts.asp?TID=1028&PID=6176
Rather than using the single-quote (') as a delimiter, you can use the double-quote
(") if you escape it. In VBS you escape a character by doubling it, so ""
. For some reason, this seems to work better in this situation.
Using the following revision, I was able to get folders with ' or } in them,
but I had to escape the backslashes ( \\ )
strFolderName = "c:\\quote_test\\b{o't}h"
Thanks David, I was able to make a few modifications based on your
comments and get a working script!