473,396 Members | 1,982 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,396 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 3330
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.