开启左侧

关于Activate的终结篇.估计不少大神都已经研究过了.应该公开

[复制链接]
AsmDebuger 发表于 2019-1-19 17:03:24 | 显示全部楼层 |阅读模式
  1. namespace AutoActivateVisionPro
  2. {
  3.     class Program
  4.     {
  5.         private static void Activate()
  6.         {
  7.             var cmd                              = new System.Diagnostics.Process();
  8.             cmd.StartInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
  9.             cmd.StartInfo.FileName               = "cmd";
  10.             cmd.StartInfo.CreateNoWindow         = true;
  11.             cmd.StartInfo.UseShellExecute        = false;
  12.             cmd.StartInfo.RedirectStandardInput  = true;
  13.             cmd.StartInfo.RedirectStandardOutput = true;
  14.             
  15.             cmd.OutputDataReceived += (sender, e) =>
  16.             {
  17.                 if (!string.IsNullOrEmpty(e.Data))
  18.                 {
  19.                     string[] outs = e.Data.Split(new char[] { '\n', '\r' });
  20.                     for (int i = 0; i < outs.GetLength(0); i++)
  21.                     {
  22.                         System.Console.WriteLine(outs[i]);
  23.                     }
  24.                 }
  25.             };
  26.             cmd.Start();
  27.             cmd.BeginOutputReadLine();

  28.             var cmdWriter = cmd.StandardInput;

  29.             // 切换到C盘
  30.             cmdWriter.WriteLine("C:");

  31.             // 获取VP的密匙管理中心的路径
  32.             string rootFolder = string.Empty;
  33.             if (System.Environment.Is64BitOperatingSystem)
  34.             {
  35.                 rootFolder = """ + "C:/Program Files (x86)/Common Files/Cognex/Software Licensing Center/" + """;
  36.             }
  37.             else
  38.             {
  39.                 rootFolder = """ + "C:/Program Files/Common Files/Cognex/Software Licensing Center/" + """;
  40.             }

  41.             // 切换执行目录到VP密匙管理中心目录
  42.             cmdWriter.WriteLine("cd " + rootFolder);


  43.             // 1. 将命名为CVL.zip的VisionPro激活备份文件添加到项目资源中
  44.             // 2. 解压该资源文件到系统临时目录
  45.             var strTmpDirectory = System.IO.Path.GetTempPath() + "CVL.zip";
  46.             System.IO.File.WriteAllBytes(strTmpDirectory, Properties.Resources.CVL);

  47.             // 加载VP激活备份文件
  48.             cmdWriter.WriteLine(@"cogslc --restore " + """ + strTmpDirectory + """);

  49.             // 执行激活命令
  50.             cmdWriter.WriteLine(@"cogslc --emergency install --edir ./Emergency/VisionPro");
  51.             cmdWriter.Close();
  52.             cmd.Close();
  53.         }


  54.         static void Main(string[] args)
  55.         {
  56.             // 需要保证程序以管理员权限运行
  57.             if (!string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("VPRO_ROOT")))
  58.             {
  59.                 Program.Activate();
  60.             }
  61.         }
  62.     }
  63. }
复制代码

---------------------
作者:zhy29563
来源:CSDN


这位同学研究的已经非常透彻了.
知足常乐 发表于 2019-1-20 12:57:41 | 显示全部楼层
大神都默默的使用的 ,你只是捅破了那层窗户纸
绝地武士 发表于 2019-1-20 13:41:53 | 显示全部楼层
老铁你又悄悄捅窗户纸
 楼主| AsmDebuger 发表于 2019-2-19 13:39:20 | 显示全部楼层
这个行业慢慢的很多技术都公开了.主要是因为.net.公开才能促进进步和提高,大势所趋,竞争是越来越激烈的.
lezzx 发表于 2019-7-18 13:25:18 | 显示全部楼层
真的有用吗?
 楼主| AsmDebuger 发表于 2019-9-28 20:25:47 | 显示全部楼层
谢谢楼上各位.将来见面记得AsmDebuger.
wenluderen 发表于 2020-4-6 09:17:40 | 显示全部楼层
感觉就是把手动激活 办成自动激活了

对应的版本应该也是 8.2吧?

9.0版本应该是不可以用的 ,对吧?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表