C# windows forms application to open cmd and enter any script.
Code will be like:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace RunCmdFOrms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
RedirectStandardInput = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
var process = new Process { StartInfo = startInfo };
process.Start();
process.StandardInput.WriteLine(@"Your command");
process.StandardInput.WriteLine("exit");
process.WaitForExit();
}
}
}
Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.