cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vijay_rb
Level 3

Environment Variables in IS2010 (InstallScript project))

Hi,

I need to add an environment variable permanently so that the installed application can use it.

1. I think the only way to do it before IS2010 was by writing to the registry.
is this right?

2. Is there a easier GUI way to just add env variables and its values in the new IS2010?

3. If there isn't, here is my current project.
I have used the IS view to copy application files (.NET) to the target.
IS2010 added a Setup.rul automatically.
It was blank until IS2010 automatically added the "OnFirstUIBefore()".
It added some labels inside this function like "Dlg_Start:", "Dlg_SdWelcome:", "Dlg_SdStartCopy2:" etc

a. Now where can I add the script to create registry values for the enviroment varibles?
This should be available to the entire system, all users and uninstallable.

Please give a small example or link.
Thanks
Vijay
Labels (1)
0 Kudos
(8) Replies
RobertDickau
Flexera Alumni

If nothing else, perhaps search the InstallShield KB or www.installsite.org > InstallScript Samples > Operating System > Handle PATH Environment on NT.
0 Kudos
vijay_rb
Level 3

Hi,

I was able to create the environment variables using InstallScript.
but now I have a new problem.

all my environment variables are new and get created in the registry.
except one, the "Path" environment variable.
This variable already exists and I used to append my path to the existing one.
but now, when I uninstall the "Path" env variable itself is getting removed from the registry !

so my question is:
1. How can I stop the path from getting removed during an uninstall?
2. If I can stop it then can I revert it back to the older path?

my scenario:
I am creating the env variables using installscript on the after last UI event.

Thanks
Vijay
0 Kudos
RobertDickau
Flexera Alumni

What code are you using? The examples in the KB and on InstallSite should call Disable(LOGGING) to prevent the whole value from being removed...
0 Kudos
GetExp
Level 6

You mean to say that if the variable "path" contains A;B as value and if you append your value C, then during the removal the complete A, B and C is getting removed? Is that right?
0 Kudos
vijay_rb
Level 3

Yes, thats exactly whats happening.
Whats the best way to stop this?

Thanks

Update:
I am using an InstallScript project.
All the move data and other stuff are being done using the InstallShield 2010 UI (no script).
Only adding the environment variables is done using InstallScript.
Installshield had added an event handler OnFirstUIAfter()
here I call my own function 'SetupEnv'.
in the SetupEnv custom function I create the registry entries using (RegDBGetKeyValueEx, RegDBSetKeyValueEx etc)
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

As Robert mentioned, logging should be disabled with Disable(LOGGING); before calling any registry functions to change environment variables. If this is not done, the registry calls will log the registry value (not the data changed) that was changed and assume it needs to be removed during uninstall.
0 Kudos
vijay_rb
Level 3

Hi ,

Thanks for the reply.
So I just need to put this line "Disable(LOGGING);" before I call the "SetupEnv" custom function that writes to the registry ?

What if I need only a few things to be kept in registry and a few other to be removed from registry on uninstall.
meaning, lets say the registry has two variables : A, B
I update A ,
don't touch B
and add a new one C

now on uninstall I need to revert back A or leave it as it is
leave B as it is
and remove C from the registry (since I added it during an install)

Lastly,
whatever I am doing, is it the right way to do things?
am I missing something?
am I doing something wrong?
can you point out a few things?



Thanks again.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

You can re-enable logging with Enable(LOGGING); if you would like to log any additional resources so that they are automatically removed during uninstall.

The approach you are using should work fine. As long as logging is enabled or disabled as needed, you should only need to test the installation to verify each scenario you expect works correctly.
0 Kudos