Click here to Skip to main content
Rate this: bad
good
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 1:52am
mulbert368
Edited 27-Jun-11 1:56am
(no name)140.5K
v2

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

  Print Answers RSS
0 OriginalGriff 490
1 Maciej Los 299
2 BillWoodruff 174
3 /\jmot 170
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 27 Jun 2011
Copyright © CodeProject, 1999-2014
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