"yawnmoth" <terra1024@yahoo.com> wrote in message
news:dc71d15a-38bd-4e55-92bb-a5543d0dff45@31g2000vbf.googlegroups.com...
On Sep 26, 1:43 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
| Quote: |
"yawnmoth" <terra1...@yahoo.com> wrote in message
news:d3667e99-694b-481c-a5e6-2bba145c6ad4@v2g2000vbb.googlegroups.com...
Events can be scheduled to run at a certain time via the Windows
Scheduler. What if you wanted to trigger an event to run during a
certain "event". ie. make it so one event triggers another?
Here you go:
@echo off
set BatchName=d:\temp\test.bat
set Scr=c:\TempVBS.vbs
set VB=echo^>^>%Scr%
cd 1>nul 2>%Scr%
%VB% Set oWshShell = CreateObject("WScript.Shell")
%VB% Set oWMIService = GetObject("winmgmts:\\.\root\wmi")
%VB% Set cMonitoredEvents = oWMIService.ExecNotificationQuery _
%VB% ("Select * from MSNDIS_StatusMediaConnect")
%VB% Do While True
%VB% Set sLatestEvent = cMonitoredEvents.NextEvent
%VB% oWshShell.Run "cmd.exe /c %BatchName% " _
%VB% ^& sLatestEvent.InstanceName
%VB% Loop
start /b cscript //nologo %Scr%
ping localhost -n 10 > nul
del %Scr%
|
Interesting. So I guess the vbscript just runs constantly, in the
background? Are there situations where it could bog down system
performance? Does cMonitoredEvents.NextEvent block until there's a
change?
Also, what other tables are there? There's
MSNDIS_StatusMediaConnect... are there any other tables?
=========
It is cscript.exe that runs constantly in the background (and that can be
killed with taskkill.exe if you so desire). I do not think that the
MSNdis_StatusMediaConnect event class causes any significant CPU loading but
then you can easily work this out for yourself by keeping the script running
for an hour before checking how much CPU time the cscript.exe process has
clocked up.
About other event classes - other than MSNDIS-StatusMediaDisconnect I do not
know. If you have a lot of patience then you can google for these two
classes. You will get some Microsoft TechNet pages which are likely to
contain a list of available classes.