MofComp 订阅不工作且保存的文件表现异常

MofComp Subscription not Working and Saved File Acting Strange

我正在尝试注册此文件 (mytest3.mof) :

#PRAGMA AUTORECOVER
#pragma namespace("\\.\root\subscription")

instance of __EventFilter as $EventFilter
{
    Name  = "Event Filter Instance Name";
    EventNamespace = "Root\Cimv2";
    Query = "Select * From __InstanceCreationEvent Within 1 "
            "Where TargetInstance Isa \"Cim_DirectoryContainsFile\" "
            "and TargetInstance.GroupComponent=\"Win32_Directory.Name=\'C:\\test\'\"";
    QueryLanguage = "WQL";
};

instance of ActiveScriptEventConsumer as $Consumer
{
    Name = "TestConsumer";
    ScriptingEngine = "VBScript";
    ScriptFileName = "C:\test\test.vbs";  
};

instance of __FilterToConsumerBinding
{
    Filter = $EventFilter;
    Consumer = $Consumer;
}; 

使用命令PS C:\windows\system32\wbem> mofcomp mytest3.mof

并收到此输出:

Microsoft (R) MOF Compiler Version 6.2.9200.16398
Copyright (c) Microsoft Corp. 1997-2006. All rights reserved.
Parsing MOF file: mytest3.mof
MOF file has been successfully parsed
Storing data in the repository...
WARNING: File mytest3.mof does not contain #PRAGMA AUTORECOVER.
If the WMI repository is rebuilt in the future, the contents of this MOF file w
ill not be included in the new WMI repository.
To include this MOF file when the WMI Repository is automatically reconstructed
, place the #PRAGMA AUTORECOVER statement on the first line of the MOF file.
Done!

现在已经发生过几次了,我可以看到该事件没有被注册。

有人知道我为什么会看到关于 #PRAGMA AUTORECROVER 的消息吗?你清楚地看到这一行已包含在文件中,但系统仍然抱怨它不存在......我不确定这是否是事件未被注册的部分原因,但似乎他们可能是相关的。

作为可能有助于解释的额外细节 - 当我将 mytset3.mof 保存在 wbem 文件夹中时,在我进入该文件夹之前无法找到该文件,创建一个新的空白文本文件并将其保存为 mytest3.mof。在我这样做之前(即使我已经保存了文档),PC 的行为就好像这个文件不存在一样......这是怎么回事?这可能与文件夹权限有关吗?

这个问题似乎是由 Notepad++

引起的

Notepad++ 保存文件时,我必须执行上述创建新空白文件的过程,然后系统才能使用它,并且 运行 mofcomp 似乎什么也不做(即使它说数据已保存到存储库)并抱怨 #PRAGMA AUTORECOVER.

将完全相同的文件内容粘贴到常规 Notepad.exe 实例并保存后,没有任何问题。文件在保存后创建,运行 mofcomp mytest4.mof 不仅 returns 终端中的成功消息而且我还可以看到事件现在已注册以监视 C:\test文件夹。

不太确定这里的 Notepad++ 发生了什么,但如果有人能阐明一些信息那就太好了!