Execute a shell command from a .NET application
.net, console, execution, shell, winforms
Solution
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "blah.lua arg1 arg2 arg3";
p.StartInfo.UseShellExecute = true;
p.Start();
Another way would be to use P/Invoke and use ShellExecute directly:
[DllImport("shell32.dll")]
static extern IntPtr ShellExecute(
IntPtr hwnd,
string lpOperation,
string lpFile,
string lpParameters,
string lpDirectory,
ShowCommands nShowCmd);
Problem
I need to execute a shell command from my .NET application, not unlike `os.execute` (a little way down on that page) in Lua. However with a cursory search I couldn't find anything. How do I do it?