Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to call external exe from C#?

Posted on 2004-08-06
6
Medium Priority
?
4,189 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

688 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