473,412 Members | 4,966 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,412 software developers and data experts.

Run batch file

Hi,
I have a batch file "MyFile.bat", and I need to run it from a C#
application.
How do I do it ?

Yoav.
Nov 17 '05 #1
3 38454
I'm not sure... try this with your *.bat file.
http://www.computing.net/programming...rum/12335.html

Arjen
"Yoavo" <yo**@cimatron.co.il> schreef in bericht
news:u4****************@TK2MSFTNGP10.phx.gbl...
Hi,
I have a batch file "MyFile.bat", and I need to run it from a C#
application.
How do I do it ?

Yoav.

Nov 17 '05 #2
Hope this is straightforward and also tested..
System.Diagnostics.Process.Start("c:\\winnt\\notep ad.exe");

Maheshkuma.R

http://spaces.msn.com/members/cyberiafreak

"Arjen" <bo*****@hotmail.com> wrote in message
news:de**********@news1.zwoll1.ov.home.nl...
I'm not sure... try this with your *.bat file.
http://www.computing.net/programming...rum/12335.html

Arjen
"Yoavo" <yo**@cimatron.co.il> schreef in bericht
news:u4****************@TK2MSFTNGP10.phx.gbl...
Hi,
I have a batch file "MyFile.bat", and I need to run it from a C#
application.
How do I do it ?

Yoav.


Nov 17 '05 #3
Hi Yoavo,
here is how you would do that with a couple of the possible options you
might want to set:

using System.Diagnostics;

ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();

//specify the nam andthe arguements you want to pass to the command prompt
psi.FileName = @"c:\test123.bat";
psi.Arguments = "1 2 3 4";

//if you don't want a console window popping up then set this property
pi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

//Create new process and set the starting information
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = psi;
//Set this so that you can tell when the process has completed
p.EnableRaisingEvents = true;
p.Start();

//wait until the process has completed
while(!p.HasExited)
{
System.Threading.Thread.Sleep(1000);
}

//check to see what the exit code was
if(p.ExitCode != 0)
{
//some error occurred
}
Hope that helps
Mark R Dawson

"Yoavo" wrote:
Hi,
I have a batch file "MyFile.bat", and I need to run it from a C#
application.
How do I do it ?

Yoav.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: SkySea | last post by:
Hi! Any help on this would be appreciated... In an HTML document that lists instructions on installing some software, there's a point where a DOS batch file needs to be run in order to copy...
1
by: Rob | last post by:
I'm running a batch file using the Shell function. When I manually launch the batch file, the window remains open, since I use the 'pause' statement. But when I launch the batch file within...
4
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup)...
4
by: carrot | last post by:
With .Net Studio, I have a solution includes some projects. I want to execute a batch file during build solution time. For example, 1'st project is builded. 2'nd project is builded. " a batch...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
3
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see...
1
by: steve | last post by:
Hi all, Here's some work in progress that should allow you to run a batch file as a custom action in a VS deployment project. Yup I know you can use js or wsh, but the target may not have...
4
ck9663
by: ck9663 | last post by:
hi guys this is a little challenging, at least for me...here goes... i have to run a DOS batch file from a server. with some parameters that i need to pass. these parameters can be found on a...
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: 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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.