最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

在asp.net(c#)下實(shí)現(xiàn)調(diào)用cmd的方法

 更新時(shí)間:2012年01月09日 11:20:01   作者:  
通常情況下我們會(huì)用到調(diào)用cmd.exe來(lái)實(shí)現(xiàn)一些命令,例如 ping ,等等
下面以ping 為例用到命名空間System.Diagnostics;
System.Diagnostics 命名空間 包含了能夠與系統(tǒng)進(jìn)程 事件日志 和性能計(jì)數(shù)器進(jìn)行交互的類 一般用于幫助診斷和調(diào)試應(yīng)用程序 例如 Debug類用于幫組調(diào)試代碼 Process類能夠控制進(jìn)程訪問(wèn) Trace類能夠跟蹤代碼的執(zhí)行情況
Process 用于操作本地或者遠(yuǎn)程進(jìn)程打訪問(wèn) 通過(guò)Process 可以在托管環(huán)境下很容易的操作對(duì)外部進(jìn)程的啟動(dòng)或者停止 。
復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace TestEqual
{
class Program
{
static void Main(string[] args)
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = "iexplore.exe";
myProcess.StartInfo.Arguments = "http://www.baidu.com";
myProcess.Start();
}

}
}

必須設(shè)置相應(yīng)的FileName和Arguments屬性
下面以ping為例
代碼如下:
復(fù)制代碼 代碼如下:

string hostname = "http://www.baidu.com"; //或者這里是ip等;
Process prc=new Process();
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
prc.StartInfo.CreateNoWindow = false;
prc.Start();
prc.StandardInput.WriteLine("ping " + hostname);
prc.StandardInput.Close();
Response.Write(prc.StandardOutput.ReadToEnd());

這里還可以調(diào)用很多命令自己可以研究下

相關(guān)文章

最新評(píng)論

贡嘎县| 响水县| 色达县| 隆化县| 聊城市| 西安市| 莫力| 大厂| 新邵县| 千阳县| 太和县| 东阿县| 和林格尔县| 通辽市| 万年县| 图们市| 东海县| 衡山县| 越西县| 桐柏县| 肇东市| 孙吴县| 汤阴县| 睢宁县| 健康| 柳江县| 衢州市| 武汉市| 微博| 安平县| 大田县| 吴桥县| 辉县市| 新丰县| 武威市| 新平| 济源市| 惠州市| 彭山县| 措美县| 华安县|