开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜