Solved

How to call external exe from C#?

Posted on 2004-08-06
6
4,183 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
[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
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
Technology Partners: 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 9

Expert Comment

by:s_sansanwal
ID: 11741326
0
 
LVL 19

Expert Comment

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

Accepted Solution

by:
psdavis earned 125 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Coding for the first time 9 94
Return array 3 30
Load XML element 3 40
RestClient.cs fails at (HttpWebResponse)request.GetResponse()) 4 45
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Suggested Courses

742 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