创建Win32_LocalTime _instancemodificationevent非重复事件

时间:2012-07-12 07:47:23

标签: events wmi wmi-query timed

我有一个问题,我似乎无法找到答案。我正在使用WMI创建一些定时事件,到目前为止它们运行良好。事件按预期在预定周期重复。我现在正在寻找一种方法来创建一个不会重复的“一次性”事件,似乎无法弄清楚或在任何地方找到答案。

以下是MSDN网站上创建重复事件的示例:

// Win32_LocalTime and Win32_UTCTime reside in root\cimv2 namespace. 
// Defining the EventNamespace allows the filter
// to be compiled in any namespace.
instance of __EventFilter as $FILT1
{
    Name  = "wake-up call";
    Query = "SELECT * FROM __InstanceModificationEvent WHERE "    
    "TargetInstance ISA \"Win32_LocalTime\" AND "
    "TargetInstance.Hour = 0 AND TargetInstance.Minute = 0 AND "
 "TargetInstance.Second = 0";
    QueryLanguage = "WQL";
    EventNamespace = "root\\cimv2";
};

// Win32_LocalTime and Win32_UTCTime reside in root\cimv2 namespace. // Defining the EventNamespace allows the filter // to be compiled in any namespace. instance of __EventFilter as $FILT1 { Name = "wake-up call"; Query = "SELECT * FROM __InstanceModificationEvent WHERE " "TargetInstance ISA \"Win32_LocalTime\" AND " "TargetInstance.Hour = 0 AND TargetInstance.Minute = 0 AND " "TargetInstance.Second = 0"; QueryLanguage = "WQL"; EventNamespace = "root\\cimv2"; };

我想要的是让它不重复。有什么想法吗?

干杯

青蛙

1 个答案:

答案 0 :(得分:0)

__InstanceModificationEvent类是一个内部事件,它报告何时对WMI类的实例进行了更改,在这种情况下正在侦听返回当前时间的Win32_LocalTime WMI类。现在,如果要创建非重复事件,可以将年,月和日属性添加到WQL参数中。

instance of __EventFilter as $FILT1
{
    Name  = "wake-up call";
    Query = "SELECT * FROM __InstanceModificationEvent WHERE "    
    "TargetInstance ISA \"Win32_LocalTime\" AND "
    "TargetInstance.Hour = 0 AND TargetInstance.Minute = 0 AND TargetInstance.Second = 0 AND "
    "TargetInstance.Year=2012 AND TargetInstance.Month=7 AND TargetInstance.Day=12";
    QueryLanguage = "WQL";
    EventNamespace = "root\\cimv2";
};