public static string GetSTInstallPath()
{
string ret = String.Empty;
var regKey = Registry.LocalMachine.OpenSubKey(ServiceTesCurrentVersionRegistryKey);
if (regKey != null)
{
var val = regKey.GetValue(InstalltionFolderValue);
if (null != val)
{
ret = val.ToString();
}
}
else
{
regKey = Registry.LocalMachine.OpenSubKey(ServiceTesCurrentVersionWOW64RegistryKey);
if (regKey != null)
{
var val = regKey.GetValue(InstalltionFolderValue);
if (null != val)
{
ret = val.ToString();
}
}
else
{
ret = GetRootDirectoryPath() ?? string.Empty;
}
}
if (!String.IsNullOrEmpty(ret))
{
ret = ret.EndsWith("\\") ? ret : (ret + "\\");
if (ret.EndsWith("\\bin\\"))
{
int endIndex = ret.LastIndexOf("\\bin\\");
if (endIndex != -1)
{
ret = ret.Substring(0, endIndex) + "\\";
}
}
}
return ret;
}
/// <summary> /// Search ServiceTestExecuter.exe in the current running process directory, /// and if not found, in the installation folder (taken from registry) /// </summary> /// <returns></returns> public bool TrySetSTRunner() { if (File.Exists(STRunnerName)) { return(true); } _stExecuterPath = Helper.GetSTInstallPath(); if ((!String.IsNullOrEmpty(_stExecuterPath))) { _stExecuterPath += "bin"; return(true); } _stCanRun = false; return(false); }