如何用js或C#运行 cmd的命令呢 我有个控件需要先注册到服务端 客户端才可以使用 就是注册难了些 需要在cmd里面输入命令才可以注册 有没有办法通过网页 实现注册呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 通过网页的话,需要降低浏览器安全性,js可以执行exe之类的可执行文件 /// <summary>/// 运行CMD命令/// </summary>/// <param name="cmd">命令</param>/// <returns></returns>public static string Cmd(string [] cmd){Process 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.AutoFlush = true;for (int i = 0; i < cmd.Length; i++){p.StandardInput.WriteLine(cmd[i].ToString());}p.StandardInput.WriteLine("exit");string strRst = p.StandardOutput.ReadToEnd();p.WaitForExit();p.Close();return strRst;}参考: js只能运行客户端的c#只能运行服务器端,两者是完全不同的 win7和XP的系统时间不相同,请问如何解决? 关于 建立web服务项目的问题 datalist 样式问题 session 列表 RequiredFieldValidator的问题 为什么我的问题总是很少有人回答?是我问的方式不对么? dg1.DataKeys[(int)E.Item.ItemIndex]到底是个什么值,我这样无法更新? asp.net中http请求原理问题,谢谢! 如何不让datalist输出table,而输出ul 怎么再IE中显示mime文件内容 高手请赐教 一个很奇怪的问题 如何不让程序提示
/// <summary>
/// 运行CMD命令
/// </summary>
/// <param name="cmd">命令</param>
/// <returns></returns>
public static string Cmd(string [] cmd)
{
Process 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.AutoFlush = true;
for (int i = 0; i < cmd.Length; i++)
{
p.StandardInput.WriteLine(cmd[i].ToString());
}
p.StandardInput.WriteLine("exit");
string strRst = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
return strRst;
}
参考:
c#只能运行服务器端,
两者是完全不同的