Solved

how to call another exe in c#

Posted on 2007-11-20
3
3,699 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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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