473,385 Members | 1,942 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.

Capture Batch file return Value

Hi guy's

I have a batch file which return's me the string output

I success to execute the batch file from C#.Net, but unable to capture return value, I need that return string to be use in rest of my application

System.Diagnostics.Process proc = new System.Diagnostics.Process();

proc.EnableRaisingEvents = false;

proc.StartInfo.FileName = "S:\\Sadad_Link\\CMD\\Getuuid.bat";

proc.Start().ToString();



This is how i execute the batch file, but for capturing return value i check all the properies for "proc" with no reasult



I will really appreciate, if somebody helps me out

Thank's in advance



Regrad

Hameed
Apr 21 '08 #1
1 2114
If your batch script only prints the string you are interested you can read the stdout that generate its execution...

Expand|Select|Wrap|Line Numbers
  1. using (StreamReader sr = proc.StandardOutput)
  2. {
  3.      myString = sr.ReadToEnd();
  4. }
You can also use piping inside your batch script to store the string in a text file and then read it from you code.

Expand|Select|Wrap|Line Numbers
  1. task1
  2. task2
  3. ...
  4. getMyString > myString.txt
  5. ...
Hope this help.
Apr 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: brad | last post by:
I am new to perl and would like to know how to check the return values of a perl program in a batch file. how can I save the return value of the perl program and use it to make decisions as to...
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...
1
by: code_wrong | last post by:
Hi, I'm reading this: http://www.catch22.net/tuts/selfdel.asp (Self Deleting Executables) and playing around with the batch file method .. trouble is I always get a command box at the end with...
0
by: Leo Heska | last post by:
Hi I haven't seen the following problem mentioned anywhere We have an application written in VB.NET which executes a batch file (named startJob.cmd). We have discovered that if that batch file...
1
by: Kannan.V [MCSD.net] | last post by:
hi, I have this situation here, I need to call a VB application (which i can code), which does some calculations on some dates and returns a date value. For simplicity lets say, i pass a date to...
2
by: Stephen | last post by:
Hi all, I want to create an app that runs a batch file which inturn runs applications. question: if I start the batch file from app1, how can app1 know that the batch file ran successfully...
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...
16
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
0
by: j101 | last post by:
I am attempting to set up Q Capture on RH Linux (x86_64) using DB2 9 fp2, but there seems to be a general problem loading a specify MQ shared library "/opt/mqm/lib/libmqm_r.so". I have MQ v6...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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...

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.