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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning error codes from VBScript through objShell.Run 2

Status
Not open for further replies.

edushkushot

Programmer
Jan 11, 2004
15
US
Hi,

If anyone can help, that would be great. I have a .hta application that calls a separate vbscript file and runs it with the objShell.Run method. However, when the separate script returns an error, I need to be able to print the error to the hta application. I can get the error returned in the script itself, but I don't know how to get it back to the hta app. Anyone have any ideas? All are welcome.

Thanks :)


G :)
 
In the hta use the Execute method instead of Run, you will gain access to the StdOut and StdErr textstreams of the executing command.
In the vbscript file, you can write to WScript.StdOut or WScript.StdErr textstream.

Hope This Help
PH.
 
Another posibility is to use a persisted local machine queue (MSMQ) if the two processes are intended to run asynchonously.

For example, sat your HTA has a button or something fancier you go through that might cause it to Run the other script. If any results are to be reported back to the HTA these could be queued.

If they happen while the HTA is still running, an event would be caused in the HTA, and the HTA could pull the message from the queue for display or action. If the HTA terminates before the background script is done the message queue would retain any such messages. Next time the HTA is run, it would still get events for these messages and could act upon them then.

This way the two scripts (HTA & WSH in this case I assume) can even run on different computers. MSMQ can even be used between computers in different Domains if needed since a one-way coupling like this can be done via a single TCP/IP port.

But for simple cases and most synchronous cases (HTA sitting awaiting termination of the WSH script) PHV's suggestion is most appropriate. This especially true if all you need is a result code like that you can return via WScript.Quit intErrorCode.
 
Thanks PHV and Dilletante! Both of your ideas helped me solve the issue. I am very appreciative. I ended up going with the objShell.Execute method because it was faster.

G :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top