If you click on the button the following event handler will be called and the command line interface would be executed.
// Event handler
protected void btnCommand_Click(object sender, EventArgs e)
System.Diagnostics.ProcessStartInfo objProcessStartInfo =
new System.Diagnostics.ProcessStartInfo("CMD.exe", "/C " + "dir");
// CMD.exe is the name of the file which will execute.
// /C is the path name.
// dir is the command which will execute in command prompt.
objProcessStartInfo.CreateNoWindow = true; // This line will not create any new window for command prompt.
objProcessStartInfo.UseShellExecute = false;
// Set UseShellExecute to specify whether to start the process by using the operating system shell.
System.Diagnostics.Process objProcess =
The above example will open the command line interface, but it will not be visible. If you want to make the command prompt visible then assign false to objProcessStartInfo.CreateNoWindow.