//获取环境变量
string processName = Environment.GetEnvironmentVariable("ComSpec");
Process myprocess = new Process();
try
{
myprocess.StartInfo.UseShellExecute = false;
myprocess.StartInfo.FileName = processName;
myprocess.StartInfo.RedirectStandardInput = true;
myprocess.Start();
string commandname = "ping http://www.baidu.com";
myprocess.StandardInput.WriteLine(commandname );
}
catch(Exception e)
{
print(e.Message);
}
dos命令那里首字母是乱码,不管换成什么命令,总是首字母乱码。