使用批处理或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

你可能感兴趣的:(exception,String,C#,null,query)