http://www.tiantiansoft.com/bbs/dispbbs.asp?boardID=40&ID=84774
用这个类:
public string myCmd(string myCommon)
{
Process process=new Process();
process.StartInfo.FileName="cmd.exe";
process.StartInfo.UseShellExecute=false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.StandardInput.WriteLine(myCommon);
process.StandardInput.WriteLine("exit");
string myResult = process.StandardOutput.ReadToEnd();
process.Close();
return myResult;
}
调用时只需要传入相应的命令行就成
我想提得菜鸟的问题:"
这段代码在C++中能用和着吗??