Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 27th June 2012, 13:37   #1
Gowrisankar
Junior Member
 
Join Date: Jun 2012
Posts: 9
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?...........

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


Thanks in advance...
Gowrisankar is offline   Reply With Quote
Old 28th June 2012, 05:00   #2
T.Slappy
Senior Member
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 376
Send a message via ICQ to T.Slappy
Try this: http://nsis.sourceforge.net/Setting_...taller_Process

Create cool looking Graphical Installers in NSIS: www.graphical-installer.com -see below
I offer NSIS scripting, C/C++/C#/Delphi programming: www.unsigned-softworks.sk
Develop NSIS projects directly in Visual Studio 2005-2012: www.unsigned-softworks.sk/visual-installer/
T.Slappy is offline   Reply With Quote
Old 29th June 2012, 07:08   #3
Gowrisankar
Junior Member
 
Join Date: Jun 2012
Posts: 9
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.....
Gowrisankar is offline   Reply With Quote
Old 29th June 2012, 10:30   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 2,811
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)

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

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