473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 3329
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DBA | last post by:
I have a windows batch file that executes a SQL Server bcp command. I would like to obtain a return code if the bcp command fails. However, I cannot seem to find the return code (if any) for bcp....
3
by: Prasad | last post by:
Hi, I have a batch file which does file manipulation, I need to call this batch file using asp.net and display the o/p of the command e.g the copy command o/p of the batch file on the browser....
1
by: David Every | last post by:
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...
14
by: jas | last post by:
I would like to redirect the output from os.system to a variable, but am having trouble. I tried using os.popen(..).read() ...but that doesn't give me exactly what i want. ...this is windows by...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
4
by: ed | last post by:
Hi all, I'm very new to vb (2nd day) and I need to create a small app that will replace my old batch file with a flashy gui. I had some experience with access 2.0 which helps ;) What I would...
7
by: Nananana | last post by:
Hi. I have 2 DB2 statements: connect select How can I create a batch file and redirect the output to a file? I would like something like this:
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
1
by: TP | last post by:
Hi everybody, I try to find a quick way to redirect the standard output of a Python command (for example: print "message") to a python variable "foobar". Ok, in this simple example, I could do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.