Archive: How to set an environment variable in system variable


How to set an environment variable in system variable
Hai,

I want to set the environment variable in system variable path for my application. How can I set that using nsis?...........:rolleyes:

For ex: C:\Program Files\Sample\bin, I want to set this path in System variable..
pls help me..


Thanks in advance...


Try this: http://nsis.sourceforge.net/Setting_...taller_Process


Hai,
Thank for your guidelines, I downloaded the plugin and update the SetEnv.dll in application path plugin folder. Also I tried the code the following code

1:The First Way
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", R0).r0'

2:The Second Way
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
SetEnv::SetEnvVar "PATH" $R0

when I using the first way code, it writes the environment variable in user variable path but it won't write in system variable path.

When I using the second way code, there is no effect on that code, it does not write the environment variable any where.

But I want to set the environment variable as in System variable path.
Pls suggest for that.......:)

thanks in advance.....:)


Changing %path% this way can corrupt the entire string if it is longer than the NSIS max string length. To be safe you should allocate and manipulate strings directly with the system plugin (kernel32::lstrcat)