ax 页面通过代码调用cmd来运行注册服务(2)_.NET概论及软件使用_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

ax 页面通过代码调用cmd来运行注册服务(2)

作者:黑客防线网安ASP维护基地 来源:黑客防线网安ASP维护基地 浏览次数:0

本篇关键词:运行注册服务调用
黑客防线网安网讯:    Builder sb = new StringBuilder(); Process p = new Process();  p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.WorkingDirectory = TextBox3...

    Builder sb = new StringBuilder();

Process p = new Process();

 

p.StartInfo.FileName = "cmd.exe";

p.StartInfo.UseShellExecute = false;

p.StartInfo.WorkingDirectory = TextBox3.Text;//"c:\";

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;

p.Start();

 

p.StandardInput.WriteLine(strExec);

 

p.StandardInput.WriteLine("exit");

 

while ((rl = p.StandardOutput.ReadLine()) != null)

{

sb.Append(rl + " ");

//Response.Write(p.StandardOutput.ReadLine());

}

return sb.ToString();

}

}
</PRE>
<PRE class=csharp name="code">路径里面指定cmd中的路径</PRE>
<PRE class=csharp name="code">因为每次运行完最好都exit一下所以就不能使用过多命令干脆直接指定初始时的路径了</PRE>
<PRE class=csharp name="code">如果不exit得话也可以,但是一定想的关闭cmd,不然服务器当机就挂了。</PRE>
<PRE class=csharp name="code"> </PRE>
<PRE class=csharp name="code">接下来不需要我说了吧。</PRE>
<PRE class=csharp name="code">轻松搞定。
</PRE>

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-14384-1.html
网站维护教程更新时间:2012-03-30 05:47:37  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer