How do I change Windows Service environment path
I need to change thw environment variable Environment.GetEnvironmentVariable("TMP") for a Windows service开发者_如何学Go 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?
Just set the environment variable in your Main or OnStart method:
Environment.SetEnvironmentVariable("TMP", @"c:\temp");
Using SetEnvironmentVariable() changes the environment only for the running instance of the process, it doesn't change the user's system environment.
精彩评论