zoukankan      html  css  js  c++  java
  • Process.Start调用CMD

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.IO;

    namespace SocketDemo {
        class Program {
            static void Main() {
                Process proc = new Process();
                proc.StartInfo.FileName = "net.exe";
                proc.StartInfo.CreateNoWindow = true;
                proc.StartInfo.Arguments = "view";
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.UseShellExecute = false;
                proc.Start();

                StreamReader sr = new StreamReader(proc.StandardOutput.BaseStream);
                string line = "";
                List<string> names = new List<string>();

                while ((line = sr.ReadLine()) != null) {
                    //                if (line.StartsWith(@"\\")) {
                    names.Add(line); //.Substring(2).TrimEnd());
                    //                }
                }

                sr.Close();
                proc.WaitForExit();

                foreach (string name in names) {
                    Console.WriteLine(name);
                }

                Console.ReadKey();
            }
        }
    }

  • 相关阅读:
    撸羊毛的一些心得体会
    GET和POST的区别
    接口测试基础
    Charles老版本教程
    【2019】Charles视频教程,接口测试工具最新教程
    关于Synchronized研伸扩展
    Java多线程之线程的协作
    十七.jmeter分布式测试
    十六.jmeter链接mysql测试
    十五.jmeter FTP服务器连接
  • 原文地址:https://www.cnblogs.com/rickiedu/p/1499794.html
Copyright © 2011-2022 走看看