string strOutput = command+c;
Process p = null;
p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(strOutput);
p.StandardInput.WriteLine("exit");
while (p.StandardOutput.EndOfStream)
{
strOutput = p.StandardOutput.ReadLine();
Console.WriteLine(strOutput);
}
p.WaitForExit();
p.Close();
Process p = null;
p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(strOutput);
p.StandardInput.WriteLine("exit");
while (p.StandardOutput.EndOfStream)
{
strOutput = p.StandardOutput.ReadLine();
Console.WriteLine(strOutput);
}
p.WaitForExit();
p.Close();
vs 本地运行相当用你登录的用户权限
在服务器要这么做,挺多设置的,而且也不是很安全。如果一定要这么做, 这里有一个链接,你参考一下
http://forums.asp.net/t/1757464.aspx/1