Old 16th August 2019, 09:17   #1
DivyaArun
Junior Member
 
Join Date: Jul 2019
Posts: 30
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 is offline   Reply With Quote
Old 16th August 2019, 16:42   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,153
Are you starting a child process that needs the variable?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th August 2019, 06:04   #3
DivyaArun
Junior Member
 
Join Date: Jul 2019
Posts: 30
Quote:
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 is offline   Reply With Quote
Old 20th August 2019, 09:01   #4
DivyaArun
Junior Member
 
Join Date: Jul 2019
Posts: 30
Hi Anders,

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

Thanks
DivyaArun is offline   Reply With Quote
Old 20th August 2019, 11:04   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,153
Take a look on the Wiki. There should be a System::Call example that sets it directly in your process (and children).

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
nsis

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump