如何检查Oracle客户端安装或不作为组件制作安装的先决条件 [英] How to check Oracle Client installed or not as prerequisite for component installtion
问题描述
我为我们的组件创建安装包。其中镨必要条件是最低版本的Oracle 8i的客户应安装在目标机器。我怎样才能做到这一点?
I am creating installation package for our component. One of the Pr-requisites is oracle client with minimum version 8i should be installed in the target machine. How can i do this?
我提及后下
有了这个我写了下面的动作。我想请与用tnsping实用
by having this i wrote the below action. I tried to check with tnsping utility.
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 。如果我收到的例外在
here i am executing tool tnsping. if i receive exception at
bufor = System.Diagnostics.Process.Start(proces);
我的结论是,Oracle客户端没有安装。
I concluded that Oracle Client is not installed.
如果这个工具可用,我得到下面的结果很
If this tool is available, i am getting below result
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 16-AUG-2
012 06:27:58
从这个结果,我解析版本和验证相同。
from this result, I am parsing version and validating the same.
这是正确的做法?任何其他更好的办法是在那里?
Is this right approach? Any other better approach is there?
推荐答案
我没有给你一个更好的答案,但我使用您的解决方案在我的应用程序,它按预期工作。
I don't have a better answer for you, but I'm using your solution in my application and it is working as expected.
这篇关于如何检查Oracle客户端安装或不作为组件制作安装的先决条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!