Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Process VBScript Help

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,66691
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Process VBScript Help
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Process VBScript Help - 11/19/2008 9:38:17 AM   
  canyouflybobby

 

Posts: 5
Score: 0
Joined: 11/19/2008
Status: offline
 

need some process monitoring script that when an application closes it kills another process on Win2k

Running Wireless card software called watcher.exe which is included in a shortcut. I'll attach a script to it.

Once watcher.exe closes i need the script to kill a process called swiapimux.exe



I have this so far my Do Loop Aint Working :o(


strComputer = "."
set wshshell = wscript.createobject("wscript.shell")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colwatcherProcess = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'watcher.exe'")

Do

Loop until colwatcherprocess.count =0

wshshell.run "c:\winnt\system32\pskill swiapimux.exe"

wscript.echo"Process Killed


My loop keeps looping and it won't run the Shell run  i want the script to stop.

 
 
Post #: 1
 
 RE: Process VBScript Help - 11/19/2008 9:45:14 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
Search the forum for examples of WMI event sinks.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to canyouflybobby)
 
 
Post #: 2
 
 RE: Process VBScript Help - 11/19/2008 3:30:45 PM   
  canyouflybobby

 

Posts: 5
Score: 0
Joined: 11/19/2008
Status: offline
==========================================================================
'
' blah'
' NAME:
'
' AUTHOR: blah
' DATE  : blah'
' COMMENT:
'
'==========================================================================
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set MySink = WScript.CreateObject( _
  "WbemScripting.SWbemSink","SINK_")

objWMIservice.ExecNotificationQueryAsync MySink, _
  "SELECT * FROM Win32_ProcessStopTrace WHERE ProcessName = 'watcher.exe'"
Set objShell = WScript.CreateObject("WScript.Shell")
While (True)
  Wscript.Sleep(1000)
Wend
Sub SINK_OnObjectReady(objObject, objAsyncContext)
On Error Resume Next
  Wscript.Echo "Win32_ProcessStopTrace event has occurred."
  objShell.Run "c:\winnt\system32\pskill.exe wahelper.exe"
  objShell.Run "c:\winnt\system32\pskill.exe swiapimux.exe"
wscript.quit
End Sub


How about this, it works on XP but not 2000 don't think it likes objWMIservice.ExecNotificationQueryAsync MySink :( I thought this would work boo hoo

< Message edited by canyouflybobby -- 11/19/2008 3:31:57 PM >

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Process VBScript Help - 11/20/2008 1:46:16 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
Sorry, I haven't had to deal with 2K for years. There are certainly differences between 2K WMI and XP WMI, but I can't remember if this is one of them or not.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to canyouflybobby)
 
 
Post #: 4
 
 RE: Process VBScript Help - 11/20/2008 8:55:45 AM   
  canyouflybobby

 

Posts: 5
Score: 0
Joined: 11/19/2008
Status: offline
Bummer I checked 2k it does not support this object.




(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Process VBScript Help - 11/20/2008 2:00:36 PM   
  canyouflybobby

 

Posts: 5
Score: 0
Joined: 11/19/2008
Status: offline
Any other suggestions ???

(in reply to canyouflybobby)
 
 
Post #: 6
 
 RE: Process VBScript Help - 11/20/2008 2:39:56 PM   
  TomRiddle


Posts: 194
Score: 4
Joined: 2/7/2008
Status: offline
 

Here is an idea

What about making the watcher shortcut open a batchfile that opens watcher.exe.  The batch file will pause untill watcher is closed and then proceed to the next line ( kill the swiapimux.exe process)
if you want to make it neater ie not seeing the black dos window, launch the batch file from a VBscript that opens it in a hidden window.
You could probably also do it by running it the watcher.exe from plain vbscript, if you do it with the right options the script will pause until watcher.exe is closed and then proceed to the kill task.

That would mean you would have to run Watcher from the shortcut, not autorun when the NextG card is installed.

Maybe there are some updates for W2k WMI

(in reply to canyouflybobby)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Process VBScript Help Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts