tags:

views:

95

answers:

3

How do I run an external program like Notepad or Calculator via a C# program?

I am new to it and I can't seem to get it correct.

+11  A: 

Use System.Diagnostics.Process.Start

Example

Probable duplicate of: How to start a process from C# (WinForms)

Mitch Wheat
+3  A: 

For example like this :

// run notepad
System.Diagnostics.Process.Start("notepad.exe");

//run calculator
System.Diagnostics.Process.Start("calc.exe");

Follow the links in Mitchs answer.

Incognito
+1  A: 

Hi this is Sample Console Application to Invoke Notepad.exe ,please check with this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Demo_Console
{
    class Program
    {
        static void Main(string[] args)
        {
            Process ExternalProcess = new Process();
            ExternalProcess.StartInfo.FileName = "Notepad.exe";
            ExternalProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
            ExternalProcess.Start();
            ExternalProcess.WaitForExit();
        }
    }
}
Ramakrishnan