惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
B
Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
C
Check Point Blog
月光博客
月光博客
L
LangChain Blog
GbyAI
GbyAI

博客园 - sh37

Newtonsoft中的几个妙用 Mvc中ViewData与TempData的区别 Silverlight中利用ListBox特性实现单选按钮组RadioButtonList和复选按钮组CheckBoxList的功能 SilverLight中Page也可使用泛型基类 cookie操作 - sh37 - 博客园 利用MessageQueue收发消息 - sh37 - 博客园 C# xmlhttp - sh37 - 博客园 使用ASP获得AD帐号 “域\用户名” - sh37 - 博客园 使用ASP.NET获得AD帐号 - sh37 - 博客园 根據xml文檔數據 給DataTable增加行 JS获取剪贴板内容的代码 - sh37 - 博客园 分页时使当前页码变色 C#生成缩略图 自動生成帶文字的圖片 常用pl/sql vb.net後台抓取網頁內容 ServerVariables集合内容列表 如何动态创建一个按纽 并给这个按纽绑上一个Onclick事件 17种常用正则表达式
C# 利用net 命令获取域用户列表 - sh37
sh37 · 2007-09-11 · via 博客园 - sh37

RunCmd("net view")
private string RunCmd(string command)
        {
             //實例一個Process類,啟動一個獨立進程
           Process p = new Process();
           //Process類有一個StartInfo屬性,這個是ProcessStartInfo類,包括了一些屬性和方法,下面我們用到了他的幾個屬性:

           p.StartInfo.FileName = "cmd.exe";           //設定程序名
           p.StartInfo.Arguments = "/c " + command;    //設定程式執行參數
           p.StartInfo.UseShellExecute = false;        //關閉Shell的使用
           p.StartInfo.RedirectStandardInput = true;   //重定向標準輸入
           p.StartInfo.RedirectStandardOutput = true;  //重定向標準輸出
           p.StartInfo.RedirectStandardError = true;   //重定向錯誤輸出
           p.StartInfo.CreateNoWindow = true;          //設置不顯示窗口

            p.Start();   //啟動
           
           //p.StandardInput.WriteLine(command);       //也可以用這種方式輸入要執行的命令
           //p.StandardInput.WriteLine("exit");        //不過要記得加上Exit要不然下一行程式執行的時候會當機
           
            return p.StandardOutput.ReadToEnd();        //從輸出流取得命令執行結果

       }