Standard output into Batch File variable

D

David Every

Hi

I have a .NET Windows Application that looks for the
existence of a process on a remote machine. When it
finishes it exits, returning either a "0" (no it doesnt
exist, or a "1" (it does exist).

If I run it from VBScript as follows:

Set WSHShell=CreateObject("Wscript.Shell")
strRet=WSHShell.Run("C:\Temp\MyApp.exe,1,True)

then strRet ends up holding the return value.

I now need to call it from a batch file instead.

I want to know if it is possible to return the value into
a variable in a batch file ? If anyone knows how to do
this I'd be very grateful
thanks
 
L

Lars-Eric Gisslén

David,

It's so many years ago since I wrote any complex Batch files. What I
remember you should be able to use the ErrorLevel in the Batch file.
ErrorLevel should return the exit code from the last executed EXE/COM file.
If you can find any information about using the ErrorLevel I think you can
solv it. One I had a Fidonet node and all programs making up the node
(server) was run from a Batch file looping between the different EXE's
depending on the exit code from each program. The whole process was looping
around until you ended it with CTRL-C.

Regards,
Lars-Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top