开发者

How do I change Windows Service environment path

开发者 https://www.devze.com 2022-12-25 05:46 出处:网络
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 Window

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号