Get BizTalk environment
Hi
with next function write in C# there is an useful tricks for determinate the BizTalk environment:
/// <summary>
/// Get the execution environment
/// </summary>
/// <returns>PRD for Production env, DEV otherwise</returns>
public string GetEnvironment()
{
try
{
string serviceBizTalkName = "";
string sRet = "";
System.Management.SelectQuery sQuery = new System.Management.SelectQuery(string.Format("select name, startname from Win32_Service where name = '{0}'", "BTSSvc$ Production BizTalk host instance name "));
using (System.Management.ManagementObjectSearcher mgmtSearcher = new System.Management.ManagementObjectSearcher(sQuery))
{
foreach (System.Management.ManagementObject service in mgmtSearcher.Get())
{
serviceBizTalkName = service["startname"].ToString();
}
}
if (serviceBizTalkName == @"domain\biztalk user host Production")
sRet = "PRD";
else
sRet = "DEV";
return sRet;
}
catch (Exception ex)
{
System.Diagnostics.EventLog myevt = new System.Diagnostics.EventLog();
myevt.Source = "BizTalk";
myevt.WriteEntry("error: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
}
return "";
}