2
我正在为我们的组件创建安装包。其中一个必备条件是具有最低版本8i的oracle客户机应安装在目标机器上。我怎样才能做到这一点?如何检查已安装或未安装的Oracle客户端作为组件安装的先决条件
我称为下方张贴
What's the best way to determine which version of Oracle client I'm running?
由具有此我写的以下动作。我试图用tnsping实用程序来检查。
string result = string.Empty;
System.Diagnostics.ProcessStartInfo proces = new System.Diagnostics.ProcessStartInfo("tnsping.exe");
proces.RedirectStandardOutput = true;
proces.CreateNoWindow = true;
proces.UseShellExecute = false;
System.Diagnostics.Process bufor;
bufor = System.Diagnostics.Process.Start(proces);
System.IO.StreamReader Output = bufor.StandardOutput;
bufor.WaitForExit(2000);
if (bufor.HasExited)
{
result = Output.ReadToEnd();
result = result.ToLower();
if (result.Contains("64-bit"))
{
is64BitOracleClient = true;
}
int verINT = result.IndexOf("version", 0, result.Length);
if (verINT != null)
{
version = result.Substring(verINT + "version".Length + 1, 8);
Version installedVersion = new Version(version);
Version expectedVersion = new Version("8.1.7.0");
if (installedVersion >= expectedVersion)
{
isVersionMatched = true;
}
}
}
这里我正在执行工具tnsping。如果我收到异常在
bufor = System.Diagnostics.Process.Start(proces);
我断定Oracle客户端没有安装。
如果这个工具是可用的,我是从这个结果得到以下结果
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 16-AUG-2
012 06:27:58
,我解析版本和验证相同。
这是正确的做法吗?还有其他更好的方法吗?