[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

keep a windows script open on windows 7

Posted on 2013-12-14
1
Medium Priority
?
228 Views
Last Modified: 2013-12-16
i have created a com object that raises events.  one of the ways shown to test this is with a vbscript run by WScipt.exe.

the problem is that the script will exit before any events are raised .. before the sub that handles the event.  how can i keep the script open long enough to get the events?

i am calling the script from a command prompt:  wscript.exe test.vbs


here is my code;
set obj = WScript.CreateObject("TestApp.Agent", "agent_")

MsgBox "Value from Init is " & obj.Init
MsgBox "Status: " + obj.StatusMesssage
MsgBox "New Session Id: " + obj.NewSessionId
MsgBox "Len: " + CStr(Len(obj.NewSessionId))

if Len(obj.NewSessionId) > 0 then
	obj.Monitor
end if


Sub agent_AgentEvent(val)
     MsgBox "Event fired - val is " & val
End Sub

Open in new window

0
Comment
Question by:dhenderson12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39718973
You'll have to implement a waiting loop, endless or with a stop condition:
Dim obj, bQuit

set obj = WScript.CreateObject("TestApp.Agent", "agent_")

MsgBox "Value from Init is " & obj.Init
MsgBox "Status: " + obj.StatusMesssage
MsgBox "New Session Id: " + obj.NewSessionId
MsgBox "Len: " + CStr(Len(obj.NewSessionId))

if Len(obj.NewSessionId) > 0 then
	obj.Monitor
end if

bQuit = false
do
  WScript.Sleep 100
loop until bQuit

Sub agent_AgentEvent(val)
     MsgBox "Event fired - val is " & val
     bQuit = true
End Sub

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question