Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Execute another program on button click

Tags:

c#

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.

like image 702
BassieBas1987 Avatar asked Apr 11 '13 12:04

BassieBas1987


2 Answers

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 ;)

like image 112
Xavjer Avatar answered Sep 29 '22 18:09

Xavjer


ProcessStartInfo start = new ProcessStartInfo();
start.FileName = @"C:\Scripts\XLXS-CSV.exe";
Process.Start(start);
like image 37
Brandon Boone Avatar answered Sep 29 '22 19:09

Brandon Boone