小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

執(zhí)行CMD命令并返回結(jié)果

 緣木求魚(yú)001 2012-09-27
執(zhí)行CMD命令并返回結(jié)果 
 
private void button1_Click(object sender, EventArgs e) 

    string[] cmd = new string[] { "ping 192.168.3.15 -n 1""ping 192.168.3.16 -n 2" }; 
    MessageBox.Show(Cmd(cmd)); 
    CloseProcess("cmd.exe"); 

 
 
public static string Cmd(string [] cmd) 

    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
    p.Start(); 
    p.StandardInput.AutoFlush = true
    for (int i = 0; i < cmd.Length; i++) 
    { 
        p.StandardInput.WriteLine(cmd[i].ToString()); 
    } 
    p.StandardInput.WriteLine("exit"); 
    string strRst = p.StandardOutput.ReadToEnd(); 
    p.WaitForExit(); 
    p.Close(); 
    return strRst; 

 
 
public static bool CloseProcess(string ProcName) 

    bool result = false
    System.Collections.ArrayList procList = new System.Collections.ArrayList(); 
    string tempName = ""
    int begpos; 
    int endpos; 
    foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses()) 
    { 
        tempName = thisProc.ToString(); 
        begpos = tempName.IndexOf("(") + 1
        endpos = tempName.IndexOf(")"); 
        tempName = tempName.Substring(begpos, endpos - begpos); 
        procList.Add(tempName); 
        if (tempName == ProcName) 
        { 
            if (!thisProc.CloseMainWindow()) 
                thisProc.Kill(); // 當(dāng)發(fā)送關(guān)閉窗口命令無(wú)效時(shí)強(qiáng)行結(jié)束進(jìn)程 
            result = true
        } 
    } 
    return result; 

 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約