Respostas:
using System.Diagnostics;
class Program
{
static void Main()
{
Process.Start("C:\\");
}
}
Se seu aplicativo precisar de argumentos de cmd, use algo como isto:
using System.Diagnostics;
class Program
{
static void Main()
{
LaunchCommandLineApp();
}
/// <summary>
/// Launch the application with some options set.
/// </summary>
static void LaunchCommandLineApp()
{
// For the example
const string ex1 = "C:\\";
const string ex2 = "C:\\Dir";
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "dcm2jpg.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}
}
Veja Process.Start e Process.StartInfo
Exemplo:
System.Diagnostics.Process.Start("mspaint.exe");
Compilando o código
Copie o código e cole-o no método Main de um aplicativo de console. Substitua "mspaint.exe" pelo caminho para o aplicativo que você deseja executar.
Process.Start()
Sei que isso está bem respondido, mas se você estiver interessado, escrevi uma biblioteca que facilita muito a execução de comandos.
Confira aqui: https://github.com/twitchax/Sheller .
startInfo.UseShellExecute = falsefoi uma coisa incrível ... Funcionou para mim como um encanto! Obrigado! :)