¿Lanzar una aplicación (.EXE) desde C#?

Resuelto rudigrobler asked hace 15 años • 9 respuestas

¿Cómo puedo iniciar una aplicación usando C#?

Requisitos: Debe funcionar en Windows XP y Windows Vista .

He visto una muestra de DinnerNow.net que sólo funciona en Windows Vista.

rudigrobler avatar Oct 27 '08 21:10 rudigrobler
Aceptado

Aquí hay un fragmento de código útil:

using System.Diagnostics;

// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
// Enter in the command line arguments, everything you would enter after the executable name itself
start.Arguments = arguments; 
// Enter the executable to run, including the complete path
start.FileName = ExeName;
// Do you want to show a console window?
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
int exitCode;


// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
     proc.WaitForExit();

     // Retrieve the app's exit code
     exitCode = proc.ExitCode;
}

Hay mucho más que puedes hacer con estos objetos, deberías leer la documentación: ProcessStartInfo , Process .

sfuqua avatar Oct 27 '2008 16:10 sfuqua

Método de uso System.Diagnostics.Process.Start().

Consulte este artículo sobre cómo usarlo.

Process.Start("notepad", "readme.txt");

string winpath = Environment.GetEnvironmentVariable("windir");
string path = System.IO.Path.GetDirectoryName(
              System.Windows.Forms.Application.ExecutablePath);

Process.Start(winpath + @"\Microsoft.NET\Framework\v1.0.3705\Installutil.exe",
path + "\\MyService.exe");
Igal Tabachnik avatar Oct 27 '2008 14:10 Igal Tabachnik
System.Diagnostics.Process.Start("PathToExe.exe");
Mark S. Rasmussen avatar Oct 27 '2008 14:10 Mark S. Rasmussen
System.Diagnostics.Process.Start( @"C:\Windows\System32\Notepad.exe" );
Adam Kane avatar Oct 13 '2009 06:10 Adam Kane