MofComp订阅无法正常工作,并且保存的文件行为异常 [英] MofComp Subscription not Working and Saved File Acting Strange

查看:160
本文介绍了MofComp订阅无法正常工作,并且保存的文件行为异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to register this file (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!

这已经发生了好几次了,我可以看到该事件没有被注册.

This has happened a few times now, and I can see that the event is not being registered.

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

Does anyone know why I am seeing the message about #PRAGMA AUTORECROVER? Youc an clearly see that this line has been included in the file, but the system still complains that it is not there ... I am not sure if this is part of the reason why the event is not being registered, but it seems like they may be related.

作为一个可能帮助解释的额外细节-当我将mytset3.mof保存在wbem文件夹中时,只有在我进入该文件夹,创建一个新的空白文本文件并将其另存为.在执行此操作之前(即使我已经保存了文档),PC仍会像该文件不存在一样工作...这是怎么回事?这可能与文件夹权限有关吗?

As an extra detail which may help to explain - when I save mytset3.mof in the wbem folder, the file cannot be found there until I enter the folder, create a new blank text file and save it as mytest3.mof. Until I do this (even though I have saved the document), the PC acts as if this file does not exist ... What is going on here? Could this be related to folder permissions?

推荐答案

此问题似乎是由Notepad++

Notepad++保存文件时,我必须执行上述过程以创建一个新的空白文件,然后再将其提供给系统使用,并且运行mofcomp似乎无济于事(即使它说数据是保存到存储库中),并抱怨#PRAGMA AUTORECOVER.

When saving the file from Notepad++ I have to do the above process of creating a new blank file before it is made available to the system, and running mofcomp appears to do nothing (even though it says the data was saved to the repository) and complains about #PRAGMA AUTORECOVER.

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

After pasting the exact same file contents into a regular Notepad.exe instance and saving that, there are no issues whatsoever. The file is created after saving, and running mofcomp mytest4.mof not only returns a successful message in the terminal but I can also see that the event is now registered to monitor the C:\test folder.

不太确定Notepad++在这里发生了什么,但是如果有人可以阐明一些观点,那就太好了!

Not quite sure what is happening with Notepad++ here but if anyone could shed some light that would be great!

这篇关于MofComp订阅无法正常工作,并且保存的文件行为异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆