471,091 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

Standard output into batch file variable

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

Nov 22 '05 #1
2 3233
On Sun, 16 Nov 2003 21:34:37 -0800, David Every wrote:
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.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 22 '05 #2
On Sun, 16 Nov 2003 21:34:37 -0800, David Every wrote:
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.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by DBA | last post: by
3 posts views Thread by Prasad | last post: by
1 post views Thread by David Every | last post: by
14 posts views Thread by jas | last post: by
6 posts views Thread by Wescotte | last post: by
14 posts views Thread by =?Utf-8?B?R2lkaQ==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.