Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asynchronously call a WSC object 1

Status
Not open for further replies.

JOB2828

Programmer
Jan 21, 2005
17
US
I need to know if there is a way to asynchronously call a wsc object. Here is a simple example of what I need to do.

set obj = createobject("some.wsc")

SOMECODE
obj.dosomething
SOMEMORECODE

Currently this script has to wait until obj.dosomething is finished before it will run SOMEMORECODE. I am looking for a way to run obj.dosomething without waiting for it to complete.

I've googled my fricken head off. Any ideas of where to look, or info in general is appreciated.

Thanks
 
you sounds like you are stuck with a blocked method call.
you could shell out to a generic vbscript or batch file whcih does the call and then your controlling script can continue on. you will then need some sort of feedback loop to find out the result...all very messy.

dilettante posted a q example using a MS com object recently...might be worth a look
 
sorry, just had to jump on the world wide waxer to find out what WSC is/was/tiz.

cant you modify the WSC so that it doesnt block the method call? i.e. (one example) the method returns an ID for the process in the WSC and you can later query the ID for the result of the actual action the method did....
 
You are right on track. I know how to write an asynchronous ("non-blocked method call") in C++, but I am having difficulty figuring out how to do this within a vbscript wsc. I suppose I could convert my WSC into a dll or ocx that will run asynchronously, but that seems like overkill. It's very fast and easy to turn an existing vbscript into a wsc. I have many scripts that are re-usable (hence the reason to convert them to a wsc), but many of them need to run asynchronously. For example a script using the wscript.shell.exec method. It calls some application and the stdout & stderr are dumped to a log file or database. I don't need the results of the exec call to be returned to the calling script or even know if and when they are completed. I simply need it to execute that method and continue on. Anyway maybe this will bring some more clarity and ideas as to the best way to accomplish this. Thanks for the reply...
 
Update...

I did find the solution. It is through WMI though.

SWbemObject.ExecMethodAsync_

You can read about it here...MSDN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top