我正在尝试注册此文件(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就好像这个文件不存在......这里发生了什么?这可能与文件夹权限有关吗?
答案 0 :(得分:0)
这个问题似乎是由Notepad++
从Notepad++
保存文件时,我必须执行上述创建新空白文件的过程才能使系统可用,并且运行mofcomp
似乎无效(即使它说数据已保存到存储库中)并抱怨#PRAGMA AUTORECOVER
。
将完全相同的文件内容粘贴到常规Notepad.exe
实例中并保存后,没有任何问题。保存后创建文件,并且运行mofcomp mytest4.mof
不仅会在终端中返回成功的消息,而且还可以看到该事件现已注册以监控C:\test
文件夹。
不完全确定Notepad++
在这里发生了什么,但是如果有人能够提出一些很棒的事情呢!