Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
For Example i have this mof file:
#pragma namespace ("\\\\.\\Root\\subscription")
instance of ActiveScriptEventConsumer as $CONSUMER
{
Name = "ExternalScriptConsumer";
ScriptingEngine = "VBScript";
ScriptFileName = "C:\\Consumer.vbs";
};
 
instance of __EventFilter as $FILTER
{
EventNamespace = "\\\\.\\Root\\Cimv2";
Name = "MyRemDevFilter2"; 
Query = "Select * From __InstanceDeletionEvent Within 2" 
"Where TargetInstance Isa \"Win32_Process\" "
"And Targetinstance.Name = \"notepad.exe\" ";
QueryLanguage = "WQL"; 
};
instance of __FilterToConsumerBinding
{
Consumer = $CONSUMER;
Filter = $FILTER;
};

And This is Consumer.vbs that i call from mof file:
strComputer = "."
strService = " 'Alerter' "
 
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")
For Each objService in colListOfServices
objService.StartService()
Next 


And now a question. I was tried write a script Consumer.vbs into $CONSUMER like in this example:
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "TestConsumer2";
ScriptingEngine = "VBScript";
ScriptText = 
"Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n"
"Set objFile = objFSO.OpenTextFile(\"c:\\log.txt\", 8, True)\n"
"objFile.WriteLine Time & \" \" & \" Notepad started stoped\"\n"
"objFile.Close\n";
};

But it's doesn't work ... Maybe because my script work with WMI too ??? Can anyone help me? Thank's ...
Posted
Updated 27-Jun-11 0:56am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900