Solved

how to call another exe in c#

Posted on 2007-11-20
3
3,708 Views
Last Modified: 2013-12-17
Hi,

I am using C# of VS .Net 2005.

I want to call another executable file (.exe)in my program.  I need to wait till executable is terminated
How can I do it?

Thanks.
0
Comment
Question by:krunalj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:wizrr
ID: 20320273
Hi.
Try something like this:
using (Process process = new Process()) {
					process.StartInfo = new ProcessStartInfo("format", " C:");
					process.Start();
					process.WaitForExit();
				}

Open in new window

0
 
LVL 15

Expert Comment

by:spprivate
ID: 20320276
There is no Shell command in C#.use the process instead
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName="your.exe";
proc.Start();
proc.WaitForExit();



0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 50 total points
ID: 20320355
Process p = new Process();
p.StartInfo.FileName = "C:\Temp\myProgram.exe";
p.StartInfo.Arguments = "My Arguments";
p.Start();
p.WaitForExit(1000) // Wait for 1 minute leave 1000 out to wait forever
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question