I have read some posts about how to write Environment Variables Permantently, but i need to write/set them on install running to test the DB Connection.
The program that connects with DataBase reads Settings from Environment Variables like DBDATE, DBTEMP, DBSERVER and others that the installer sets into installoptions 'forms'/'pages', but i need them on the environment to test the connection on the next page, but i only read about reading env. vars. and write them on the registry or the autoexec, but this option needs to reboot.
Resume: How Can I write/change Env. Vars. on installer execution?
Thanks
Environment Variables:: Write/Change Them?
16 posts
Hi there, this is how i would write an environment variable
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Env Name" "Env Value"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Env Name" "Env Value"
That only works on Windows NT. The functions I have posted above work with Windows 9x too.
RePlay: sorry about my english, but maybe i said something different that i thonk (thonk? thinked? what is the past of to think?)
Example:
One Install Script
PAge 1 Welcome
Page 2 License
Page 3 Components
Page 4 Custom Page With Input Text Boxes
Page 5 Custom Page With DB connection test
Page 6 Custon Page that shows information about connection
Page 7 Install Rest of Components
Page 8 Bye Bye
In The Page 6 i read a file written by Program on Page 5
In The Page 5 i call an executable that read the Environment Variables to Test an DataBase Connection.
In the Page 4 i do an input of the variables that i need in the Page 5.
In The solutions that you give me, i need to install,reboot and test de connection,
if the connection dont work the user must repeat the install!?!?!
Resume: How Can I Change/SetUp/Write Variables to Environment Directly during execution, not to registry, not to autoexec.bat?
Example:
One Install Script
PAge 1 Welcome
Page 2 License
Page 3 Components
Page 4 Custom Page With Input Text Boxes
Page 5 Custom Page With DB connection test
Page 6 Custon Page that shows information about connection
Page 7 Install Rest of Components
Page 8 Bye Bye
In The Page 6 i read a file written by Program on Page 5
In The Page 5 i call an executable that read the Environment Variables to Test an DataBase Connection.
In the Page 4 i do an input of the variables that i need in the Page 5.
In The solutions that you give me, i need to install,reboot and test de connection,
if the connection dont work the user must repeat the install!?!?!
Resume: How Can I Change/SetUp/Write Variables to Environment Directly during execution, not to registry, not to autoexec.bat?
past of think is thought
I am sorry. I haven't read your question to the end. 🙁
Here is how you do it without the need to create a plug-in:
If you don't want to include System.dll in your installer (9KB) then you'll have to write a nice little plug-in that calls SetEnvironmentVariable.
Here is how you do it without the need to create a plug-in:
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("name", "value").r0'
StrCmp $0 0 error
Exec "other proggie.exe" Replace "name" with the name of the environment variable and "value" with it's value. Repeat this line (System::Call...) for every variable you need to set.If you don't want to include System.dll in your installer (9KB) then you'll have to write a nice little plug-in that calls SetEnvironmentVariable.
thank you! 👍
it works fine,
at the moment i will use the system.dll, in future... maybe a new little dll.
it works fine,
at the moment i will use the system.dll, in future... maybe a new little dll.
Does this work with nsExec as well?
Or just for the Exec functions?
---
Thanks
Or just for the Exec functions?
---
Thanks
Yes, it works for nsExec as well as both use CreateProcess.
--- La Función - The Function ---
--- Post in Spanish ---
Hola
La función System::Call funcionó bien, hasta que empecé a realizar debug y control de errores, fue entonces cuando descubri que cada vez que se utiliza la función, el flag de error se activa, y pierdo el control de los errores, y se me escapa por algun lado.
¿tengo alguna otra manera de hacer lo mismo con otro dll ya existente?
Muchas Gracias y Saludos Totales :P
KiKoLo
--- Post in Spanish ---
--- Post in ... Spanglish? ---
Hi
The Function System::Call worked fine, but when i started to do debug and error hadler control, i discover that when i use the function, the error flag activates, and i miss the control of the error handles and it scapes anywhere.
¿Can i do the same with an existent dll?
Lots of Thanks and SALUDOS TOTALES :P
KiKoLo
--- Post in ... Spanglish? ---
--- Ejemplo - Example ---
Thank you for all darkboy 😉
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("name", "value").r0'--- La Función - The Function ------ Post in Spanish ---
Hola
La función System::Call funcionó bien, hasta que empecé a realizar debug y control de errores, fue entonces cuando descubri que cada vez que se utiliza la función, el flag de error se activa, y pierdo el control de los errores, y se me escapa por algun lado.
¿tengo alguna otra manera de hacer lo mismo con otro dll ya existente?
Muchas Gracias y Saludos Totales :P
KiKoLo
--- Post in Spanish ---
--- Post in ... Spanglish? ---
Hi
The Function System::Call worked fine, but when i started to do debug and error hadler control, i discover that when i use the function, the error flag activates, and i miss the control of the error handles and it scapes anywhere.
¿Can i do the same with an existent dll?
Lots of Thanks and SALUDOS TOTALES :P
KiKoLo
--- Post in ... Spanglish? ---
--- Ejemplo - Example ---
Name "Tester"
OutFile "..\bin\testing.exe"
Section "Testing"
Push $R0
StrCpy $R0 "I"
DetailPrint "DEBUG_TRACE[$0]: (REG) INFODB = [$R0]"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("INFODB", "$R0").r0'
DetailPrint "DEBUG_TRACE[$0]: (ENV) INFODB = [$R0]"
Pop $R0
SectionEnd --- Ejemplo - Example ---Thank you for all darkboy 😉
!define Spanish_Post 😛
KiKoLo: Tu mensaje en el foro está bien redactado, les explicas que
tienes un error al usar el plugin System al usar Debug, y que este
error no lo puedes controlar.
Ayuda el hecho de que hayas puesto parte de tu código.
!define English_Post 😉
KiKoLo: you post in english is ok. When you use the System plugin with
the debug and error handlers, you starting to recived error that you
can't handle...
It helps that you put part of your code.
KiKoLo: Tu mensaje en el foro está bien redactado, les explicas que
tienes un error al usar el plugin System al usar Debug, y que este
error no lo puedes controlar.
Ayuda el hecho de que hayas puesto parte de tu código.
!define English_Post 😉
KiKoLo: you post in english is ok. When you use the System plugin with
the debug and error handlers, you starting to recived error that you
can't handle...
It helps that you put part of your code.
I made a plugin dll (SetEnv.dll) to do this.
And Works when the other way doesnot
explanation...
The file is the SetEnv Plugin, anybody knows how can i upload it to downloads section in the official page?
Thanks for everybody and...
¡¡¡Saludos Totales!!!!
yeah!
KiKoLo
NOTAS
NOTA 1: No tengo ni puta idea de C, pero con los ejemplos que tenian, y el msdn, no fue dificil hacerlo.
NOTA 2: Mi inglés es pésimo, está oxidado asi que si alguien no lo entiende, lo siento, es hasta donde puedo llegar
NOTA 3: Descomprimir quedando SenEnv como un directorio mas del Contrib debajo del NSIS (NSIS\Contrib\SetEnv) porque coge el ..\exdll\exdll.h y despues mover el setenv.dll a NSIS\Plugins
NOTES
NOTE 1: I have no idea about C, but with the examples anda with the MSDN it does not be dificult to do.
NOTE 2: Sorry about my english 😁
NOTE 3: Extract It on a Dir behind Contrib 'cause it take the ..\exdll\exdll.h and then move the setenv.dll to NSIS\Plugins
And Works when the other way doesnot
explanation...
Name "Tester"
OutFile "..\bin\testing.exe"
Section "Testing"
Push $R0
Push $R1
StrCpy $R0 "PATH"
ReadEnvStr $R1 "$R0"
MessageBox MB_OK "Before Modify Var: PATH = $R1"
StrCpy $R1 "C:\MYAPP;$R1"
MessageBox MB_OK "Before Set Env Var: PATH = $R1"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("$R0", "$R1").r0'
ReadEnvStr $R1 "$R0"
MessageBox MB_OK "After Set and Get: PATH = $R1"
Pop $R1
Pop $R0
SectionEnd If I replace the system call withMessages:
Before Modify Var: PATH = C:\Archivos de Programa\TextPad 4;P:\Bin_Unstable;D:\UTILES\MKSNT;C:\WINNT\System32;C:\WINNT;C:\WINNT\System32\WBem;"C:\Archivos de Programa\Norton\Ghost\";"C:\Archivos de programa\NullSoft\NSIS";D:\UTILES\COMP
---
Before Set Env Var: PATH = C:\MYAPP;C:\Archivos de Programa\TextPad 4;P:\Bin_Unstable;D:\UTILES\MKSNT;C:\WINNT\System32;C:\WINNT;C:\WINNT\System32\WBem;"C:\Archivos de Programa\Norton\Ghost\";"C:\Archivos de programa\NullSoft\NSIS";D:\UTILES\COMP
---
After Set and Get : PATH =
SetEnv:SetEnvVar "$R0" "$R1" It Works and the last message shows likeAfter Set and Get : PATH = C:\MYAPP;C:\Archivos de Programa\TextPad 4;P:\Bin_Unstable;D:\UTILES\MKSNT;C:\WINNT\System32;C:\WINNT;C:\WINNT\System32\WBem;"C:\Archivos de Programa\Norton\Ghost\";"C:\Archivos de programa\NullSoft\NSIS";D:\UTILES\COMP
The file is the SetEnv Plugin, anybody knows how can i upload it to downloads section in the official page?
Thanks for everybody and...
¡¡¡Saludos Totales!!!!
yeah!
KiKoLo
NOTAS
NOTA 1: No tengo ni puta idea de C, pero con los ejemplos que tenian, y el msdn, no fue dificil hacerlo.
NOTA 2: Mi inglés es pésimo, está oxidado asi que si alguien no lo entiende, lo siento, es hasta donde puedo llegar
NOTA 3: Descomprimir quedando SenEnv como un directorio mas del Contrib debajo del NSIS (NSIS\Contrib\SetEnv) porque coge el ..\exdll\exdll.h y despues mover el setenv.dll a NSIS\Plugins
NOTES
NOTE 1: I have no idea about C, but with the examples anda with the MSDN it does not be dificult to do.
NOTE 2: Sorry about my english 😁
NOTE 3: Extract It on a Dir behind Contrib 'cause it take the ..\exdll\exdll.h and then move the setenv.dll to NSIS\Plugins
Please attach in .zip, because someone could not have the WinRAR program. (I don't have!)
jeje, i don't have winzip 😁
but a serious app like winrar give you the posibility to compress to an uneficient algorithm like winzip xDDDD (dont worry, is a joke)
I only have winrar 'cause it give me more flexibility and better ratios, but winzip is more... more... marketizing XD
Saludos Totales
but a serious app like winrar give you the posibility to compress to an uneficient algorithm like winzip xDDDD (dont worry, is a joke)
I only have winrar 'cause it give me more flexibility and better ratios, but winzip is more... more... marketizing XD
Saludos Totales
The problem is that you have quotes inside that environment variable. You can use it this way:
StrCpy $R0 "name"
StrCpy $R1 "value"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i(R0, R1).r0'
StrCmp $0 0 error
Exec "other proggie.exe" Replace StrCpy with whatever function you need and it should work. If it doesn't try putting a dot before R0 and R1 in the System::Call line. Try one of them, and try both, not sure which one should work.