• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
bobird的学习笔记
博客园    首页    新随笔    联系   管理    订阅  订阅

使用批处理或C#代码 注册ArcEngine Runtime授权,自动检测AE Runtime安装位置

ArcEngine Runtime 9.3版本,注册程序为其安装目录下的bin/SoftwareAuthorization.exe

安装位置在注册表中有记录:具体项为:

HKLM/SOFTWARE/ESRI/ArcGIS Engine Runtime

下的InstallDir值

授权文件名称为ecp后缀的,此处命名为lic.ecp

安装授权文件的参数为SoftwareAuthorization.exe -lif "lic.ecp" -s

 

其中-lif为指定授权文件,-S为不弹出界面

使用批处理文件处理过程:

1 检索注册表获取安装目录,拼装为完整路径,

2 使用参数注册授权文件

批处理方式下具体代码如下:

@echo off 
for /f "tokens=1,2,* " %%i in ('REG QUERY "HKLM/SOFTWARE/ESRI/ArcGIS Engine Runtime" ^| find /i "InstallDir"') do set "RegPath=%%kbin/SoftwareAuthorization.exe" 
"%RegPath%" -lif "lic.ecp" -S
ECHO 注册完成
PAUSE

C#方式:

#region 注册Engine Runtime9.3
        private int RegEngineRuntime(string targetDirectory)
        {
            try
            {
                string licPathAndPram = "";
                RegistryKey EngineRuntimeKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE/ESRI/ArcGIS Engine Runtime", true);
                if (EngineRuntimeKey != null)
                {
                    licPathAndPram = EngineRuntimeKey.GetValue("InstallDir").ToString()+@"bin/SoftwareAuthorization.exe";
                }
                Process pRuntimeReg = new Process();
                pRuntimeReg.EnableRaisingEvents = true;
                pRuntimeReg.StartInfo.FileName = licPathAndPram;
                pRuntimeReg.StartInfo.Arguments = "-lif " + targetDirectory + @"/lic.ecp -S" ;//其中“/s”,注册成功后,不提示成功消息
                pRuntimeReg.Start();   
                pRuntimeReg.WaitForExit();
                return pRuntimeReg.ExitCode;
            }
            catch (Exception e)
            {
                return -1;
            }
        }
        #endregion

 

 

 

posted on 2013-06-27 09:09  bobird  阅读(316)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3