Hi all,
I've encountered what seems to be a limitation in how WMI reads object
paths when I use an ASSOCIATORS OF WQL query or the AssociatorsOf()
method. If the object path contains the right curly brace character (}),
WMI always returns 0x80041017 (invalid query syntax).
To reproduce this issue, I created a directory called C:\Test}Dir and
put two subdirectories in it called Dir1 and Dir2. Next, I ran the
following short script:
Dim Computer, WMI, Subdirs, Subdir
Computer = "."
Set WMI = GetObject("winmgmts:{impersonationlevel=impersonate}!//" _
& Computer & "/root/cimv2")
Set Subdirs = WMI.ExecQuery("Associators Of " _
& "{Win32_Directory.Name='C:\Test}Dir'} Where " _
& "AssocClass=Win32_Subdirectory ResultRole=PartComponent")
For Each SubDir In Subdirs
WScript.Echo Subdir.Name
Next
If I rename the directory and remove the "}" character (and edit the
query in the script accordingly), it behaves as expected and enumerates
the subdirectories.
There's no mention of "}" being a special character, or how to escape it
to prevent this, in Microsoft's reference:
http://msdn.microsoft.com/library/d...ements.asp
Using a double quote character (") in the object path in place of the
single quote doesn't work either; WMI returns 0x8004103A (invalid object
path).
Has anyone else encountered this issue? Am I doing something wrong, is
this a bug, or is there a workaround?
Thanks
Bill Stewart
Replies