I need to change thw environment variable Environment.GetEnvironmentVariable(“TMP”) for a Windows service in .NET 2.0 that is running with its own user account. The server is a Windows Server 2003, SP2. Can anybody tell me how to change the Windows environment variable for that user?
I need to change thw environment variable Environment.GetEnvironmentVariable(TMP) for a Windows service in .NET
Share
Just set the environment variable in your Main or OnStart method:
Using SetEnvironmentVariable() changes the environment only for the running instance of the process, it doesn’t change the user’s system environment.