Standard output into batch file variable

  • Thread starter Thread starter David Every
  • Start date Start date
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
 
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

A batch file supports the ERRORLEVEL keyword for getting the return value
from a program.

CALL ProgNameThatReturnsAValue
IF ERRORLEVEL 1 <somecommand>

Be aware that the IF command above will evaluate to true if the ERRORLEVEL
is greater than or equal to 1. So if the prog returns the value 2, for
example, the IF above still evaluates to TRUE.
 

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

Back
Top