Setting Environment Variables to Active Installer Process: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(A/W fix)
 
(15 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{PageAuthor|KiKoLo}}
{{PageAuthor|KiKoLo}}


;The Same in Spanish Language at Bottom, search !ifdef LANG_SPANISH
== English Section ==
== English Section ==
=== Links ===
=== Links ===
Line 24: Line 23:
=== Examples ===
=== Examples ===
You must change PATH to %PATH%;C:\MYAPP
You must change PATH to %PATH%;C:\MYAPP
; The Fist Way:
; The First Way:
<highlight-nsis>
<highlight-nsis>
ReadEnvStr $R0 "PATH"
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
StrCpy $R0 "$R0;C:\MYAPP"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", "$R0").r0'
System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("PATH", R0).r0'
</highlight-nsis>
</highlight-nsis>


Line 38: Line 37:
</highlight-nsis>
</highlight-nsis>


NOTE: If i do a plugin is because the first way do not run properly with my scripts... maybe i am doing something wrong. :?
== Spanish Section ==
 
=== Enlaces ===
=== !endif ===
 
== !ifdef LANG_SPANISH ==
=== Links ===
Para Descargarse el plugin, cogerlo desde el foro del nsis en estos enlaces:
Para Descargarse el plugin, cogerlo desde el foro del nsis en estos enlaces:


Line 50: Line 45:
[http://forums.winamp.com/attachment.php?s=&postid=893433 setenv.zip]
[http://forums.winamp.com/attachment.php?s=&postid=893433 setenv.zip]


=== Description ===
=== Descripción ===
Esta p�gina trata solo de como cambiar variables de entorno del proceso del intalador
Esta página trata solo de como cambiar variables de entorno del proceso del instalador
; Relacionado (s�lo ingl�s):
; Relacionado (sólo inglés):
: [[Setting Environment Variables]] por [[user:kichik:KiCHiK]]
: [[Setting Environment Variables]] por [[user:kichik|KiCHiK]]


Hay dos maneras que yo sepa para cambiar las variables de entorno
Hay dos maneras que yo sepa para cambiar las variables de entorno


; La Primera:
; La Primera:
: Puedes usar el plugin system.dll y llamar a la funci�n 'call' para llamar a la funci�n del nucleo de Windows (kernel32) 'SetEnvironmentVariable'
: Puedes usar el plugin system.dll y llamar a la función 'call' para llamar a la función del nucleo de Windows (kernel32) 'SetEnvironmentVariable'


; La Segunda:
; La Segunda:
Line 69: Line 64:
ReadEnvStr $R0 "PATH"
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
StrCpy $R0 "$R0;C:\MYAPP"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", R0).r0'
System::Call 'Kernel32::SetEnvironmentVariable(t "PATH", t R0)i.r0'
</highlight-nsis>
</highlight-nsis>


Line 79: Line 74:
</highlight-nsis>
</highlight-nsis>


NOTA: Si he hecho el plugin es porque la primera manera no funciona correctamente con mis scripts.... quiz� este haciendo algo mal. :?
[[Category: Disk, Path & File Functions]]
 
[[Category: System Related Functions]]
=== !endif ===
 
[[Category:Disk, Path & File Functions]]

Latest revision as of 22:56, 14 January 2021

Author: KiKoLo (talk, contrib)


English Section

Links

To Download the plugin, take it from the NSIS forum at this link:

setenv.rar

setenv.zip

Description

This page is related only to how to change variables environment to the Installer Process.

Related to
Setting Environment Variables by KiCHiK

There are two ways that i know to change the environment variables

The First Way
You can use the system.dll plugin and in the code call to de SetEnvironmentVariable on the windows kernel
The Second Way
Use a custom plugin, that do this, and this is that i made. :)

Examples

You must change PATH to %PATH%;C:\MYAPP

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

Spanish Section

Enlaces

Para Descargarse el plugin, cogerlo desde el foro del nsis en estos enlaces:

setenv.rar

setenv.zip

Descripción

Esta página trata solo de como cambiar variables de entorno del proceso del instalador

Relacionado (sólo inglés)
Setting Environment Variables por KiCHiK

Hay dos maneras que yo sepa para cambiar las variables de entorno

La Primera
Puedes usar el plugin system.dll y llamar a la función 'call' para llamar a la función del nucleo de Windows (kernel32) 'SetEnvironmentVariable'
La Segunda
Usar un plugin personalizado, que haga esto. Y esto es lo que yo he hecho. :)

Ejemplos

Tienes que cambiar PATH a %PATH%;C:\MYAPP

La Primera Manera
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
System::Call 'Kernel32::SetEnvironmentVariable(t "PATH", t R0)i.r0'
La Segunda Manera
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
SetEnv::SetEnvVar "PATH" $R0