【问题标题】:How to check Oracle Client installed or not as prerequisite for component installtion如何检查是否安装了 Oracle 客户端作为组件安装的先决条件
【发布时间】:2012-08-16 09:19:27
【问题描述】:

我正在为我们的组件创建安装包。先决条件之一是目标机器上应安装最低版本 8i 的 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

根据这个结果,我正在解析版本并验证它。

这是正确的方法吗?还有其他更好的方法吗?

【问题讨论】:

    标签: c# windows oracle installation


    【解决方案1】:

    我没有更好的答案给你,但我在我的应用程序中使用了你的解决方案,它按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-04
      • 1970-01-01
      • 2022-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多