国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.Net執行cmd命令的實現代碼

2024-07-10 12:41:54
字體:
來源:轉載
供稿:網友
代碼如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Diagnostics;
namespace WebForm
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(ExeCommand("ping www.126.com"));
}
public string ExeCommand(string commandText)
{
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;
string strOutput = null;
try
{
p.Start();
p.StandardInput.WriteLine(commandText);
p.StandardInput.WriteLine("exit");
strOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
}
catch (Exception e)
{
strOutput = e.Message;
}
return strOutput;
}
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 榆社县| 东阳市| 鹤山市| 远安县| 开封县| 台东县| 苍山县| 壤塘县| 渭南市| 南涧| 康平县| 龙胜| 犍为县| 连城县| 兖州市| 射洪县| 余庆县| 乐昌市| 通化市| 台中市| 东阿县| 全州县| 泗洪县| 德江县| 玉门市| 焉耆| 嵊州市| 平度市| 那曲县| 桃园县| 马尔康县| 留坝县| 尼玛县| 沭阳县| 鲁甸县| 怀安县| 武胜县| 永年县| 铅山县| 全南县| 都昌县|