Solved

how to call another exe in c#

Posted on 2007-11-20
3
3,673 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 62

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now