Archive: Setting Environment Variables


Setting Environment Variables
hello,
I am new to the NSIS installer.During installation i need to set values for environment variables,like (classpath for java etc)
How do i do this,
thanks in advance
-vrunda


This should do the trick:

http://nsis.sourceforge.net/archive/....php?pageid=91

Unless you want to temporarily set it for just the current process and sub-processes you will run from the installer and then you'll need:

http://forums.winamp.com/showthread....ht=environment


hello,
could not make it work,i need to set the variable values for system variables,
with the following code
StrCpy $1 "value"
WriteRegStr HKU "Environment" "variable" $1
i am not able to set the values for the variable.but with same code i can set the value for current user variables.
how do i do this,
is any simple way out to this,other than .dll etc?
thanks
-Vrunda


Oops, sorry... Wrong link.

Here is the right one:
http://forums.winamp.com/showthread....ht=writeenvstr


hello,
thanks for the reply,but could not open the code link :( FYI i am working on windows 2000 platform.
Why i am not able to set the variable values for all users(like other system variables) with the code
StrCpy $1 "value"
WriteRegStr HKU "Environment" "variable" $1
How do i do this?
thanks in advance
-Vrunda


HKU is not the right place to write it. I have created a new archive page that explains it all:
http://nsis.sourceforge.net/archive/...instances=0,11

Have a look at the ALL_USERS define I have added, that's what you need.


hello
not working on NT platform.
The code in the .nsi file is

!verbose 3
!include functions.nsh
!verbose 4

Section
Push "JAVA_HOME"
Push "c:\jdk"
Call WriteEnvStr
SectionEnd

Section uninstall
# remove the variable
Call un.DeleteEnvStr
SectionEnd

and the
.nsh file has the functions in the code given by you.
no error is generated,and still the value is not set. :(
How do i do this.
thanks in advance
-Vrunda


According to this code the environment variable will be written into HKCU\Environment. You didn't define ALL_USERS before including functions.nsh. Are you sure it's not in HKCU\Environment? If it's not, attach your script and I will create a testing script for you.


hello,
sorry for the delay in reply.Was a bit busy in some other issues. the .nsi file code goes like this

;The name of the installer
Name "TEMP"

;The file to write
OutFile "Temp.exe"

InstallDir $WINDIR\Temp2


;Texts on the dialogs

InstType Typical
!define ALL_USERS

!verbose 3
!include "functions.nsh" ;includes the script provided by you
!verbose 4

Section "Add to path"
PUSH "USERDIR"
PUSH "c:/temp1"
Call WriteEnvStr
SectionEnd
Waiting for your reply
thanks in advance
-Vrunda Divekar


Please try the latest NSIS, version 2.0b2. There was a bug with the defines.


Please get the latest code too as there was a "Control\" missing in the registry path. Together with NSIS 2.0b2 it should really work this time ;) I have tested it yet again and it worked.

http://nsis.sourceforge.net/archive/...instances=0,11


hello,
The new code you have given works well :) thanks very much
thanks and regards
-Vrunda