Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

358
Vistas
Resolved |// Execute command in CMD [C#]

So basically, I Want to execute a command in cmd because i need to open Paint from it, Code i tried:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C mspaint.exe, openFileDialog1.FileName;"
process.StartInfo = startInfo;
process.Start();

Can someone help me? I Want to execute paint with a png file choose by user.

Thanks Trevor for helping, Maybe the other code will work.

            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName = "cmd.exe";
            startInfo.Arguments = "/C mspaint.exe, " + openFileDialog1.FileName;
            process.StartInfo = startInfo;
            process.Start();

Code working fine

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

To open a specific file using mspaint you can specify the file path as an argument (without any comma):

mspaint <filePath>

From the code you can do the following:

Process proc = new Process
{
    StartInfo = new ProcessStartInfo
    {
        FileName = "cmd.exe",
        Arguments = $"/C mspaint.exe {openFileDialog1.FileName}",
        WindowStyle = ProcessWindowStyle.Hidden
    }
};

proc.Start();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda