0

I'm currently having trouble applying logon script(powershell) on windows servers. The logon script has the line to set user environment variables but the variables don't look like being applying immediately from the result of set command on command prompts. I've been looking at the behavior through process monitor while logging on to the new session. And finally I have found the newly created variables need to be associated with RegenerateUserEnvironment function on shell32.dll. I'm able to look at the correct result of set command after RegenerateUserEnvironment is called.

So I was wondering whether we had a way to trigger RegenerateUserEnvironment function and it needs to be executed on powershell.

Can you shed some light on this?

Best Regards, Haewon

  • 1
    Processes usually only read the environment when they're launched. If you update environment variables afterwards, processes won't recognize that until they're restarted. – Ansgar Wiechers Sep 17 '19 at 15:20
  • Thanks for your response. I’m aware of what you’re meaning. But from the result of my test, the newly created environment variables aren’t applied until RegenerateUserEnvironment is called under explorer.exe process. It basically takes about 15 seconds to be applied. – 정해원 Sep 18 '19 at 00:12

0 Answers0