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();
}}
}
必須設置相應的FileName和Arguments屬性
下面以ping為例
代碼如下:
代碼如下:
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());
這里還可以調用很多命令自己可以研究下
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com