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();
}

posted @ 2009-11-24 23:48  greencolor  阅读(156)  评论(0编辑  收藏  举报