I have a Windows Service which runs under a domain account (which is not an Administrator).
I am starting a Thread in the Windows Service, The thread internally creates a Task. Now the Task tries to setup few Environment Variables at Process Level using,
Environment.SetEnvironmentVariable("var_name","value");
That's when I get below Error:
System.Security.SecurityException: Requested registry access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(string name, Boolean writable)
at System.Environment.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
....... followed by the code Stack Trace.
Would anyone be able to help please?
Note: I can neither set the environment at Machine level due to constraint from Risk team nor at User Level as the user is used by multiple application and variable value might clash(so not suggested).