Exec Class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to be able to execute programs directly from a C# program. My first
thought was to use exec, but the documentation states that exec should not be
called directly from application code. Any suggestions on what should be used
to start executable programs directly from C# code?

Thanks,
Randy
 
Hi Randy,

To start executables simply use:

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "calc.exe";
p.Start();
[p.WaitForExit();]

Alex
http://devkids.blogspot.com
 
randy1200 said:
I need to be able to execute programs directly from a C# program. My first
thought was to use exec, but the documentation states that exec should not
be
called directly from application code. Any suggestions on what should be
used
to start executable programs directly from C# code?

Use the Process class. In its simplest form, you just do
Process.Start(program);
 
Randy,

Exec? Exec is a task for MSBuild, which is meant to run a program
during your build process (should you specify it).

What you are looking for is the Process class. It will allow you to
start programs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top