Click here to Skip to main content
12,403,130 members (72,567 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VBScript Windows scripting , +
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 27-Jun-11 0:52am
mulbert368
Updated 27-Jun-11 0:56am
Prerak Patel141.7K
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 27 Jun 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100