10

I want to write a class with similar funcionality as the .NET ManagementPath class. On MSDN is a set of articles which handles the format of object paths. However, I don't understand it yet with all special cases

  • String comparisons that deal with object paths are always case-insensitive. ==> does this also apply to the values of keys when querying for object instances?

  • Hexadecimal constants for integers. ==> where can they occur? in values of keys only?

  • Boolean constants for classes with keys that take Boolean values. ==> what are the constants? true / false? 0 / 1?

  • An assumed local server with a partial namespace path. Thus, specifying the root and default namespace implies the root and default namespace on the local server. ==> does this only mean that if I don't specify a server, that then "." is used as server?

  • No white space either within an element or between elements. ==> why does the original .NET implementation allow spaces in server names then?

  • Embedded quotation marks in object paths are allowed but must delimit the quotation mark with escape characters, as in a C or C++ application. ==> ???

  • Only decimal values are recognized as numeric portions of keys. ==> ???

  • Everything on this page: http://msdn.microsoft.com/en-us/library/aa389223(v=VS.85).aspx ==> ?

Well, the basic paths that I think are valid look like

\\Server\Namespace
        \Namespace
\\Server\Namespace:Class
        \Namespace:Class
                   Class
\\Server\Namespace:Class.KeyName=KeyValue
        \Namespace:Class.KeyName=KeyValue
                   Class.KeyName=KeyValue
\\Server\Namespace:Class=KeyValue
        \Namespace:Class=KeyValue
                   Class=KeyValue
\\Server\Namespace:Class.FirstKey=FirstValue,SecondKey=SecondValue
        \Namespace:Class.FirstKey=FirstValue,SecondKey=SecondValue
                   Class.FirstKey=FirstValue,SecondKey=SecondValue
\\Server\Namespace:Class=@
        \Namespace:Class=@
                   Class=@
as well as all combinations were the \\ is replaced by a // and/or the 
\ between server and namespace is replaced by /

Have I forgotten anything here?

This is what can be extracted from MSDN. However, how may the individual tokens look like? This is what I think it may be:

KeyValue = "string"      <-- string
           1             <-- numeric
           0x1           <-- hex
           ??????????    <-- about the "decimal value" thing and 
                             "embedded quitation mark" thing. 
                             Also, what about whitespaces? 
                             do they have to be abreviated by %20?

KeyName / Class / Server
         = string without : or / or \ inside and maybe only [a-z0-9_] ? 

Namespace 
         = string without : or / inside and maybe only [a-z0-9_\]
        (.NET implementation also buggy here. accepts forward slashes regardless of 
          "You cannot use forward slashes within namespace names." on MSDN)
            Also, are they allowed to start with \ and end with a : ?

It would be very helpful if for each token a regular expression could be given of how it looks like.

Etan
  • 17,014
  • 17
  • 89
  • 148
  • Are you wanting us to read MSDN for you, write your code for you, or both? What's wrong with the .NET ManagementPath class? – Gordon Leigh Oct 09 '11 at 17:38
  • 2
    I want to write a class similar to ManagementPath in an environment where I don't have the original class available. Therefore, I need to understand what the exact spec for WMI object paths is. And as I've said, the ManagementPath class is buggy at several points and accepts input which is definitely not correct. Also, as you may notice, MSDN was already read and important info extracted to the question. – Etan Oct 10 '11 at 09:03

1 Answers1

1

Probably you can get useful information seeing the source code of the class.

If you want to test a string to be a match or not of a regex, you can use a tester.

good luck.

robermorales
  • 3,293
  • 2
  • 27
  • 36
  • 1
    probably not the detailed answer he was hoping for but valuable pointers to get there on his own, though I'd really appreciate a followup from someone with a detailed answer. – mtijn Oct 14 '11 at 10:10
  • source code link appears dead. – Will I Am May 20 '22 at 21:52