Solved

How to call external exe from C#?

Posted on 2004-08-06
6
4,169 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

26 Experts available now in Live!

Get 1:1 Help Now