Setting Environment Variables to Active Installer Process: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (Adding new author and category links.)
Line 1: Line 1:
{|align=right
{{PageAuthor|KiKoLo}}
|<small>Author: [[{{ns:2}}:KiKoLo|KiKoLo]] ([[{{ns:3}}:KiKoLo|talk]], [[{{ns:-1}}:Contributions/KiKoLo|contrib]])</small>
 
|}
<br style="clear:both;">
;The Same in Spanish Language at Bottom, search !ifdef LANG_SPANISH
;The Same in Spanish Language at Bottom, search !ifdef LANG_SPANISH
== !ifdef LANG_ENGLISH ==
== !ifdef LANG_ENGLISH ==
Line 85: Line 83:
=== !endif ===
=== !endif ===


[[{{ns:14}}:Disk, Path & File Functions]]
[[Category:Disk, Path & File Functions]]

Revision as of 13:49, 24 June 2005

Author: KiKoLo (talk, contrib)


The Same in Spanish Language at Bottom, search !ifdef LANG_SPANISH

!ifdef LANG_ENGLISH

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 Fist Way
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i(PATH, $R0).r0'
The Second Way
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
SetEnv::SetEnvVar "PATH" $R0

NOTE: If i do a plugin is because the first way do not run properly with my scripts... maybe i am doing something wrong. :?

!endif

!ifdef LANG_SPANISH

Links

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

setenv.rar

setenv.zip

Description

Esta p�gina trata solo de como cambiar variables de entorno del proceso del intalador

Relacionado (s�lo ingl�s)
Setting Environment Variables por user:kichik: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::SetEnvironmentVariableA(t, t) i(PATH, $R0).r0'
La Segunda Manera
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;C:\MYAPP"
SetEnv::SetEnvVar "PATH" $R0

NOTA: Si he hecho el plugin es porque la primera manera no funciona correctamente con mis scripts.... quiz� este haciendo algo mal. :?

!endif