Get from control panel

using System.Diagnostics;

private void button1_Click(object sender, EventArgs e)
{
    Process vProcess
= new Process();
    vProcess.StartInfo.FileName
= "cmd.exe";
    vProcess.StartInfo.UseShellExecute
= false;
    vProcess.StartInfo.RedirectStandardInput
= true;

vProcess.StartInfo.RedirectStandardOutput = true;
    vProcess.StartInfo.RedirectStandardError
= true;
    vProcess.StartInfo.CreateNoWindow
= false;

    vProcess.Start();
    vProcess.StandardInput.WriteLine(
@"dir d:\"); 

    vProcess.StandardInput.WriteLine("exit");
    textBox1.Text
= vProcess.StandardOutput.ReadToEnd();
    vProcess.Close();
}

原文地址:https://www.cnblogs.com/greencolor/p/1609955.html