A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » General XP issues or comments
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

scheduling an event whenever i connect to a wired network



 
 
Thread Tools Display Modes
  #1  
Old September 26th 09, 06:57 PM posted to microsoft.public.windowsxp.general
yawnmoth
external usenet poster
 
Posts: 136
Default scheduling an event whenever i connect to a wired network

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?
Ads
  #2  
Old September 26th 09, 07:43 PM posted to microsoft.public.windowsxp.general
Pegasus [MVP]
external usenet poster
 
Posts: 2,361
Default scheduling an event whenever i connect to a wired network


"yawnmoth" wrote in message
...
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 1nul 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%

Line 2 contains a reference to the command you wish to execute when you plug
in your network cable, d:\temp\test.bat in this case. It might contain the
following lines:
@echo off
echo %date% %time:~0,5% %* d:\test.txt

To make maintenance easier, you could combine the two batch files in a
single batch file and invoke either one component or the other, depending on
the parameter you supply.


  #3  
Old September 26th 09, 10:39 PM posted to microsoft.public.windowsxp.general
yawnmoth
external usenet poster
 
Posts: 136
Default scheduling an event whenever i connect to a wired network

On Sep 26, 1:43*pm, "Pegasus [MVP]" wrote:
"yawnmoth" wrote in message

...

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 1nul 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?
  #4  
Old September 26th 09, 11:03 PM posted to microsoft.public.windowsxp.general
Pegasus [MVP]
external usenet poster
 
Posts: 2,361
Default scheduling an event whenever i connect to a wired network


"yawnmoth" wrote in message
...
On Sep 26, 1:43 pm, "Pegasus [MVP]" wrote:
"yawnmoth" wrote in message

...

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 1nul 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.


  #5  
Old September 27th 09, 09:09 AM posted to microsoft.public.windowsxp.general
Pegasus [MVP]
external usenet poster
 
Posts: 2,361
Default scheduling an event whenever i connect to a wired network


"yawnmoth" wrote in message
...
On Sep 26, 1:43 pm, "Pegasus [MVP]" wrote:
"yawnmoth" wrote in message

...

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 1nul 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?

==============

Correction: It's probably both cscript.exe and wmiprvse.exe that you need to
monitor when checking processor loading.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 11:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.