Skip to content
⌘ NSIS Forum Archive

How to refresh environment variable without reboot

5 posts

DivyaArun#

How to refresh environment variable without reboot

Hi,

I have a requirement where based on an account type selected an environment variable will be set which will be later used by one of my library to store a log file. Though the environment variable is set when I manually check the system, but reading through code gives me empty value. Hence the log is not generated in the path.

I have read that environment variables require reboot in order to read through ReadENVStr. All the above process occurs while running installer. Hence I cannot reboot. Please help!!

Thanks
DivyaArun#
Originally Posted by Anders View Post
Are you starting a child process that needs the variable?
I have a custom page which has 2 radio buttons. And based on the radio button selection, Install Dir is set to C:\Program Files or LocalAppData folder. And this value is set to Environment Variable . Later as I proceed in one of the custom pages, I am starting a background worker, which then writes a log file to the path read from Environment variable
DivyaArun#
Hi Anders,

Do you know whether reboot is necessary for environment variable value to reflect?

Thanks
Anders#
Take a look on the Wiki. There should be a System::Call example that sets it directly in your process (and children).