private static void SetEmptyEnvironmentVariable(string key) {
// System.Environment.SetEnvironmentVariable interprets an empty value string as
// deleting the environment variable. So we use the native SetEnvironmentVariable
// function here which allows setting of the value to an empty string.
// This will require high trust and will fail in sandboxed environments
if (!NativeMethods.SetEnvironmentVariable(key, String.Empty)) {
throw new ExternalException("SetEnvironmentVariable failed", Marshal.GetLastWin32Error());
}
}
#endif