获取电脑系统唯一GUID

软件使用微软系统的唯一ID绑定指定电脑

 class Program
    {
        static void Main(string[] args)
        {
            string sysId = "";
            Process da = new Process();
            da.StartInfo.FileName = "cmd.exe";
            da.StartInfo.Arguments = "/k cscript %WINDIR%\\SYSTEM32\\SLMGR.VBS /DTI";
            da.StartInfo.UseShellExecute = false;       //是否使用操作系统shell启动
            da.StartInfo.RedirectStandardInput = true;  //接受来自调用程序的输入信息
            da.StartInfo.RedirectStandardOutput = true; //由调用程序获取输出信息
            da.StartInfo.RedirectStandardError = true;  //重定向标准错误输出
            da.StartInfo.CreateNoWindow = true;         //不显示程序窗口
            da.Start();                                 //启动程序
            da.StandardInput.WriteLine("exit");
            string strRst = da.StandardOutput.ReadToEnd();
            string[] readLine = strRst.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            string id = readLine[2].Split(':')[1].Trim();
            sysId = id;
            Console.WriteLine(sysId);
            Console.ReadKey();
        }
    }

 

posted @ 2019-01-04 15:31  流光霁雨  阅读(3090)  评论(0编辑  收藏  举报