MofComp Subscription not Working and Saved File Acting Strange

会有一股神秘感。 提交于 2019-12-12 03:28:29

问题


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;
}; 

using the command PS C:\windows\system32\wbem> mofcomp mytest3.mof

And receiving this output :

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.

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.

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?


回答1:


It would appear that this issue is somehow being caused by Notepad++

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.

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.

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



来源:https://stackoverflow.com/questions/36886755/mofcomp-subscription-not-working-and-saved-file-acting-strange

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!