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

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:25:23
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


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 "));
}
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;
}
}
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 随州市| 林甸县| 亳州市| 清丰县| 金塔县| 奈曼旗| 长岭县| 沙坪坝区| 遵义县| 肥西县| 交城县| 阿坝| 江口县| 宁远县| 张北县| 西昌市| 札达县| 阳朔县| 鹿邑县| 安达市| 黑龙江省| 本溪| 修文县| 连山| 邯郸市| 山东省| 南川市| 遂川县| 平塘县| 白山市| 凭祥市| 阿尔山市| 阳西县| 泰兴市| 巴里| 呼玛县| 淮北市| 庆城县| 门源| 汪清县| 莫力|