<div class="content" name="ExecNotificationQuery" uuid="b83ac7b7-80bf-412e-9a0f-c665fac0b5bf"><p>The IWbemServices::ExecNotificationQuery method provides a
subscription for event notifications. When this method is invoked, the server
runs a query to deliver events matching the query. The call is executed <a href="6837a7cb-ba2d-46b1-802c-fce2fd5a6ad6#gt_51f3288a-1aea-49f6-96a1-91f368e8b49b" data-linktype="relative-path">semisynchronously</a> and MUST
follow the rules that are specified in section <a href="c40421d8-b195-4268-884f-a4e74ea58dce" data-linktype="relative-path">3.1.1.1.2</a>. The WMI client
can poll the returned enumerator for events as they arrive. Releasing the
returned enumerator cancels the query.</p><dl>
<dd>
<div><pre> HRESULT ExecNotificationQuery(
   [in] const BSTR strQueryLanguage,
   [in] const BSTR strQuery,
   [in] long lFlags,
   [in] IWbemContext* pCtx,
   [out] IEnumWbemClassObject** ppEnum
 );
</pre></div>
</dd></dl><p><b>strQueryLanguage: </b>MUST be set to
&#34;WQL&#34;.</p><p><b>strQuery: </b>MUST contain the <a href="6837a7cb-ba2d-46b1-802c-fce2fd5a6ad6#gt_46e519f1-d1f0-4dcc-bd02-9a2638c03d98" data-linktype="relative-path">WQL</a> event-related query
text as specified in section <a href="6c8a38f4-4ee1-47cb-99f1-b42718a575ce" data-linktype="relative-path">2.2.1</a>.
This parameter MUST NOT be NULL.</p><p><b>lFlags: </b>Specifies the behavior of the
IWbemServices::ExecNotificationQuery method. Flag behavior MUST be interpreted
as specified in the following table.</p><dl>
<dd>
<p>The server MUST allow any combination of zero or
more flags from the following table and MUST comply with all the restrictions
in a flag description. Any other DWORD value that does not match a flag
condition MUST be treated as not valid.</p>
</dd>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>WBEM_FLAG_USE_AMENDED_QUALIFIERS 0x00020000</td>
  <td>If this bit is not set, the server SHOULD return no CIM localizable information. If this bit is set, the server SHOULD return CIM localizable information for the CIM object, as specified in section 2.2.6.</td>
 </tr><tr>
  <td>WBEM_FLAG_RETURN_IMMEDIATELY 0x00000010</td>
  <td>If this bit is set, the server MUST make the method call semisynchronously. This flag MUST always be set.</td>
 </tr><tr>
  <td>WBEM_FLAG_FORWARD_ONLY 0x00000020</td>
  <td>If this bit is set, the server MUST return an enumerator that does not have reset capability, as specified in section 3.1.4.4. This flag MUST always be set.</td>
 </tr></tbody></table>
</dd></dl><p><b>pCtx: </b>MUST be a pointer to an <a href="18c8f1a1-652f-43b7-9186-6098bc303a8d" data-linktype="relative-path">IWbemContext</a> interface,
which MUST contain additional information that the client wants to pass to the
server. If <i>pCtx</i> is NULL, the parameter MUST be ignored.</p><p><b>ppEnum: </b>MUST receive the pointer to the
IEnumWbemClassObject that is used to enumerate through the <a href="6837a7cb-ba2d-46b1-802c-fce2fd5a6ad6#gt_8d8f4b2c-bf33-4964-b55c-96ac2cc999bb" data-linktype="relative-path">CIM objects</a> that are
returned for the query result set. This parameter MUST NOT be NULL.</p><p><b>Return Values: </b>This method MUST return an
HRESULT value that MUST indicate the status of the method call. The server MUST
return WBEM_S_NO_ERROR (as specified in section <a href="a2899649-a5a3-4b13-9ffa-d8394dcdac63" data-linktype="relative-path">2.2.11</a>) to indicate the
successful completion of the method.</p><dl>
<dd>
<p><b>WBEM_S_NO_ERROR</b> (0x00)</p>
</dd></dl><p>The <a href="6837a7cb-ba2d-46b1-802c-fce2fd5a6ad6#gt_f3ef2572-95cf-4c5c-b3c9-551fd648f409" data-linktype="relative-path">security
principal</a> that makes the call MUST have WBEM_ENABLE and WBEM_REMOTE_ENABLE
accesses to the namespace; otherwise, WBEM_E_ACCESS_DENIED MUST be returned. </p><p>In response to IWbemServices::ExecNotificationQuery, the
server MUST evaluate the <i>strQuery</i> and <i>strQueryLanguage</i> parameters
(as specified in this section) and MUST return all events that match the query.
The method MUST fail if the method parameters or their combinations are not
valid as specified earlier in this section, or if the server is unable to
execute the method. Because the stream of events that are returned by the
server is not finite, the method IWbemServices::ExecNotificationQuery MUST NOT
be executed <a href="6837a7cb-ba2d-46b1-802c-fce2fd5a6ad6#gt_4dccb43d-a5c2-450f-9c9c-cadb68ecbd3e" data-linktype="relative-path">synchronously</a>.
As previously specified, this request MUST fail because the method parameters
are not valid.</p><p>For each provider in the <b>ProviderTable</b> where <b>EventQueryList</b>
is not empty:</p><ul><li><p><span><span> 
</span></span>For each query in <b>EventQueryList</b>, the server MUST check
whether the instance of a CIM class passed as part of <i>strQuery</i> is a
logical subset of the query.</p>
</li></ul><p>If no query is matched, the server MUST return
WBEM_E_INVALID_CLASS.</p><p>If <i>strQuery</i> is evaluated successfully, the server
MUST create an entry (row) in the <i>EventBindingTable</i>. If <i>strQuery</i>
includes a <b>WITHIN</b> clause, then the server MUST create an
EventPollingTimer, set its interval to the number of seconds specified in the
WITHIN clause, and start the timer. If <i>strQuery</i> includes a <b>GROUP
WITHIN</b> clause, then the server MUST create an <b>EventGroupingTimer</b> and
set its interval to the number of seconds specified in the <b>GROUP WITHIN</b>
clause. The server MUST set <b>ClientSecurityContext</b> to
RpcImpersonationAccessToken.Sids[UserIndex]). The server response to
out-of-range time intervals is implementation-dependent.<a id="Appendix_A_Target_52"></a><a aria-label="Product behavior note 52" href="27182640-aa3f-43b6-941f-a77d25f798e8#Appendix_A_52" data-linktype="relative-path">&lt;52&gt;</a></p><p>If either WITHIN or GROUP WITHIN clause is specified, the
server MUST query for the instances of the underlying CIM class (for which the
notifications are requested) in the <i>strQuery</i> and populate <b>EventBindingTable.PrevInstances</b>
with the list of instances.</p><p>The server MUST delete the row when the client releases all
references to the IEnumWbemClassObject Interface returned in ppEnum. If <i>strQuery</i>
specified an <b>EventPollingTimer</b>, the server MUST also cancel the timer.
If <i>strQuery</i> specified an <i>EventGroupingTimer</i>, the server MUST also
cancel the timer.</p><p>The server SHOULD enforce a maximum length for the <i>strQuery</i>
parameter, and return WBEM_E_QUOTA_VIOLATION if the limit is exceeded.<a id="Appendix_A_Target_53"></a><a aria-label="Product behavior note 53" href="27182640-aa3f-43b6-941f-a77d25f798e8#Appendix_A_53" data-linktype="relative-path">&lt;53&gt;</a></p><p>If the FROM clause of <i>strQuery</i> represents a class
that is not derived from __Event, the server MUST return
WBEM_E_NOT_EVENT_CLASS.</p><p>If the GROUP BY clause of <i>strQuery</i> does not have
WITHIN specified, the server MUST return WBEM_E_MISSING_GROUP_WITHIN.</p><p>If the GROUP BY clause of <i>strQuery</i> was used with
aggregation that is not supported, the server MUST return
WBEM_E_MISSING_AGGREGATION_LIST.</p><p>If the GROUP BY clause of <i>strQuery</i> references an
object that is an embedded object without using Dot notation, the server MUST
return WBEM_E_AGGREGATING_BY_OBJECT.</p><p>If WITHIN clause is not specified as part of <i>strQuery</i>
that contains an intrinsic event class, the server MUST return
WBEM_E_REGISTRATION_TOO_PRECISE.</p><p>If the <i>strQuery</i> is not syntactically valid or one or
more elements in &lt;PROPERTY-LIST&gt; contains undefined properties, the
server MUST return WBEM_E_INVALID_QUERY.</p><p>The failed method execution MUST set the value that is
referenced by the output parameters to NULL and MUST return an error in the
format specified in section 2.2.11.</p></div>