Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1.97 KB

implementing-cross-namespace-permanent-event-subscriptions.md

File metadata and controls

50 lines (40 loc) · 1.97 KB
description ms.assetid ms.tgt_platform title ms.topic ms.date
It is recommended that all permanent subscriptions be compiled into the \\root\\subscription namespace.
6d4ccc86-f29f-4ca5-bea5-c77ee07d7789
multiple
Implementing Cross-Namespace Permanent Event Subscriptions
article
05/31/2018

Implementing Cross-Namespace Permanent Event Subscriptions

It is recommended that all permanent subscriptions be compiled into the \root\subscription namespace. This prevents the need to compile the permanent consumer into each namespace being used, which means that there is only one namespace to look for permanent subscriptions. Use the EventNamespace property of __EventFilter to implement a cross-namespace subscription.

When using the CommandLineEventConsumer, it is important to secure the executable you are launching. If the executable is not in a secure location, or secured with a strong access control list (ACL), anyone can replace your executable with one of their own. For more information about ACLs, see Creating a Security Descriptor for a New Object in C++.

The following Managed Object Format (MOF) code example shows a cross-namespace subscription.

#pragma namespace("\\root\\subscription")

instance of __EventFilter as $FLT
{
  Name = "Filter";
  Query = "SELECT * FROM __InstanceModificationEvent "
          "WHERE TargetInstance ISA \"Win32_LocalTime\" "
          "AND TargetInstance.Hour = 8 "
          "AND TargetInstance.Minute = 0 "
          "AND TargetInstance.Second = 0 "
          "AND TargetInstance.DayOfWeek = 6";
  QueryLanguage = "WQL";
  EventNamespace = "root\\cimv2";
};

instance of CommandLineEventConsumer as $CONS
{
  ExecutablePath = "cmd.exe";
  ShowWindowCommand = 7;
  RunInteractively = true;
};

instance of __FilterToConsumerBinding
{
  Consumer = $CONS;
  Filter = $FLT;
};