2

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?

i referred below post

What's the best way to determine which version of Oracle client I'm running?

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;
                        }
                    }
                }

here i am executing tool tnsping. if i receive exception at

bufor = System.Diagnostics.Process.Start(proces);

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?

Community
  • 1
  • 1
Manikandan
  • 673
  • 3
  • 12
  • 26

1 Answers1

0

I don't have a better answer for you, but I'm using your solution in my application and it is working as expected.

invertigo
  • 6,336
  • 5
  • 39
  • 64