/// <summary> /// Returns a fresh copy of the system environment as an IDictionary<string,string>. /// </summary> /// <returns>The environment variables.</returns> public static IDictionary <string, string> GetEnvironmentVariables() { IDictionary environmentVariables = System.Environment.GetEnvironmentVariables(); IDictionary <string, string> result = new Dictionary <string, string>(environmentVariables.Count); foreach (DictionaryEntry entry in environmentVariables) { try { result.Add((string)entry.Key, (string)entry.Value); } catch { _instance.LogWarning("Could not read environment variable '" + entry + "', skipping."); } } return(result); }