in diagutil/Program.cs [75:120]
static void FindSqldiag()
{
try
{
bool is64bit = false;
XmlDocument ConfigDoc = new XmlDocument();
ConfigDoc.Load(@"pssdiag.xml");
string sqlver = ConfigDoc["dsConfig"]["Collection"]["Machines"]["Machine"]["Instances"]["Instance"].Attributes["ssver"].Value;
// SQL 2008 and 2008 R2 share the same tools so we call the same routine for both versions
if (sqlver == "10.50")
sqlver = "10";
string plat = ConfigDoc["dsConfig"]["DiagMgrInfo"]["IntendedPlatform"].InnerText;
String x86Env = Environment.GetEnvironmentVariable("CommonProgramFiles(x86)");
if (x86Env != null)
{
is64bit = true;
}
string tools = (string)Registry.GetValue(string.Format(@"HKEY_LOCAL_MACHINE\" + @"SOFTWARE\Microsoft\Microsoft SQL Server\{0}0\Tools\ClientSetup", sqlver), "Path", null);
string toolswow = (string)Registry.GetValue(string.Format(@"HKEY_LOCAL_MACHINE\" + @"SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\{0}0\Tools\ClientSetup", sqlver), "Path", null);
string toolsbin = tools;
if (is64bit == true && plat.Trim().ToUpper() == "I386" && System.IO.File.Exists(toolswow)) //last condition: if a pure 2008 R2 is isntalled sqldiag.exe WOW is not shipped
{
toolsbin = toolswow;
}
if (!System.IO.File.Exists(toolsbin + "sqldiag.exe"))
{
System.Windows.Forms.MessageBox.Show("Unable to find SQL Server client tools such as sqldiag.exe from this machine. Data collection will fail");
}
Console.WriteLine(sqlver + "~" + toolsbin);
}
catch (Exception ex)
{
Console.WriteLine("Error occured in findSqldiag");
Console.WriteLine(ex.ToString());
}
}