5

I have a C# Windows Form application. I want to execute another program that is in the same directory with a button click. I only need this code to execute another program.

I have the following code:

    using System.Diagnostics;

    private void buttonRunScript_Click(object sender, EventArgs e)
    {
        System.Diagnostics.ProcessStartInfo start = 
                                        new System.Diagnostics.ProcessStartInfo();
        start.FileName = @"C:\Scripts\XLXS-CSV.exe";
    }

How can I make this work properly? It is not doing anything right now.

1
  • Try to search SO, there are many good questions and answers on the same subject! Commented Apr 11, 2013 at 12:08

3 Answers 3

16

Why are u using a ProcessStartInfo, you need a Process

Process notePad = new Process();    
notePad.StartInfo.FileName   = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs"; // if you need some
notePad.Start();

This should work ;)

Sign up to request clarification or add additional context in comments.

1 Comment

Properties .HasExited and .ExitCode may be useful.
5
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = @"C:\Scripts\XLXS-CSV.exe";
Process.Start(start);

Comments

5
Process yourProcess = new Process();
yourProcess.StartInfo.FileName = @"C:\Scripts\XLXS-CSV.exe";

yourProcess.Start();

You missed to call the Start method and to use the Process class. :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.