kikolo
6th February 2003 10:18 UTC
Environment Variables:: Write/Change Them?
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
Mark_Ive
6th February 2003 11:25 UTC
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"
kichik
6th February 2003 11:26 UTC
That only works on Windows NT. The functions I have posted above work with Windows 9x too.
kikolo
6th February 2003 13:42 UTC
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?
Sunjammer
6th February 2003 13:53 UTC
past of think is thought
kichik
6th February 2003 17:10 UTC
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:
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.
kikolo
7th February 2003 08:59 UTC
thank you! :up:
it works fine,
at the moment i will use the system.dll, in future... maybe a new little dll.
iceman_k
21st February 2003 16:04 UTC
Does this work with nsExec as well?
Or just for the Exec functions?
---
Thanks
kichik
21st February 2003 16:05 UTC
Yes, it works for nsExec as well as both use CreateProcess.
kikolo
10th March 2003 09:02 UTC
--- La Función - The Function ---
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***91;$0***93;: (REG) INFODB = ***91;$R0***93;"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("INFODB", "$R0").r0'
DetailPrint "DEBUG_TRACE***91;$0***93;: (ENV) INFODB = ***91;$R0***93;"
Pop $R0
SectionEnd
>
--- Ejemplo - Example ---
Thank you for all darkboy