1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WMIQUERY anomaly

Discussion in 'Support' started by vefatica, Jul 19, 2014.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    If I ask for exactly the number of items available, I get them. If I ask for more than is available, I don't get an error message for the first failure. Starting at index 0 doesn't help (and causes the first item to be returned twice).
    Code:
    v:\> do i=1 to 7 ( echo %i &  wmiquery . "SELECT StartTime from Win32_logonsession" %i )
    1
    20140611115217.443054-240
    2
    20140719191920.059415-240
    3
    20140715105813.866117-240
    4
    20140611115217.427453-240
    5
    6
    Error (SYS): Incorrect function.
    7
    Error (SYS): Incorrect function.
    
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    I was using WMIQUERY to help debug an app of my own so I can (vaguely) guess what might be happening (because I was bitten by it).
    Say there are 4 objects available and I (as TCC user) ask for the 5th one. If TCC first asks for 4, that will succeed. If it then asks for the next (IEnumWbemClassObject::Next) 1, hr will be WBEM_S_FALSE which is > 0 and does not trigger the FAILED(hr) test. OTOH, if I ask for the 6th (or later) one and TCC first asks for 5 (or more), you'll get the WBEM_S_FALSE earlier (and you're apparently catching it in that case)
    (Or something like that).
     

Share This Page