Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to call external exe from C#?

Posted on 2004-08-06
6
Medium Priority
?
4,191 Views
Last Modified: 2011-09-20
How can I call an external application from C#? I don't necessarily need to know anything about it after I launch it, I just need to launch it (although having the handle would be nice.). In VB6 I would have just used the SHELL command kind of like this:

SHELL("C:\Notepad.exe")

Does C# have an equivalent?
0
Comment
Question by:stat792
6 Comments
 
LVL 69

Expert Comment

by:Callandor
ID: 11738184
It's called Exec(cmdname, commandExecOption, variantIn, variantOut, handled)
0
 
LVL 69

Expert Comment

by:Callandor
ID: 11738187
Parameters
CmdName
The name of the command to execute.
ExecuteOption
A vsCommandExecOption constant specifying the execution options.
VariantIn
A value passed to the command.
VariantOut
A value passed back to the invoker Exec method after the command executes.
handled
True indicates that the command was implemented. False indicates it was not.
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 11738414
using System.Diagnostics;
Process notepad = Process.Start("notepad.exe");

You can then monitor and control the process using the members of the Process class.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessClassTopic.asp
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 11741975
just call
System.Diagnostics.Process.Start("notepad.exe");
0
 
LVL 7

Accepted Solution

by:
psdavis earned 500 total points
ID: 11754823
I go with the more difficult route.

            Process proc = new Process();

            proc.EnableRaisingEvents = false;
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            proc.StartInfo.FileName = "osql";
            proc.StartInfo.Arguments = "-U sa -P test -d master -i test.sql -o vmsdblog.txt";
            proc.Start();
            proc.WaitForExit();
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

877 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