zoukankan      html  css  js  c++  java
  • nbtstat a ip 获取MAC地址等

            //nbtstat -a ip 获取MAC地址等
            public static string cmdNbtstat(string macIp2)
            {
                string hostname2 = "               ";
                string domain2 = "               ";
                string username2 = "               ";
                string mac2 = "               ";

                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = "nbtstat";
                process.StartInfo.Arguments = "-a "+macIp2;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.RedirectStandardOutput = true;

                process.Start();

                string output = process.StandardOutput.ReadToEnd();
                int hostname2Length = output.IndexOf("<00>  UNIQUE");
                int domain2Length = output.IndexOf("<00>  GROUP");
                int username2Length = output.LastIndexOf("<03>  UNIQUE");
                int mac2Length = output.IndexOf("MAC Address = ");

                if (hostname2Length > 0)
                {
                    hostname2 = output.Substring(hostname2Length - 15, 15);
                }

                if (domain2Length > 0)
                {
                    domain2 = output.Substring(domain2Length - 15, 15);
                }

                if (username2Length > 0)
                {
                    username2 = output.Substring(username2Length - 15, 15);
                }

                if(mac2Length>0)
                {
                    mac2 = output.Substring(mac2Length+14, 17);
                }
                process.WaitForExit();
                return hostname2 + domain2 + username2 + mac2.Replace("-", ":").Trim();
            }

  • 相关阅读:
    Programming WCF Services作者序
    《软件设计精要与模式》书评
    Programming WCF Services翻译笔记(九)
    检验团队是否敏捷的四个标准
    Programming WCF Services翻译笔记(八)
    Oracle BIEE (Business Intelligence) 11g 11.1.1.6.0 学习(3)创建一个简单的分析
    oracle express 11g 创建表空间
    vmware8安装win2008 r2后找不到网卡驱动的解决办法
    javascript:巧用eval函数组装表单输入项为json对象
    javascript:二叉搜索树 实现
  • 原文地址:https://www.cnblogs.com/mossan/p/749846.html
Copyright © 2011-2022 走看看