This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- System variable PATH
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 04, 2007
10:02 AM
System variable PATH
Hello!
I need to add the installation directory of my programm () to the environment system variable PATH.
I tried a lot of, but nothing I do works, so I hope that anybody can help me.
thanks, Hannes
I need to add the installation directory of my programm (
I tried a lot of, but nothing I do works, so I hope that anybody can help me.
thanks, Hannes
(7) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 04, 2007
02:41 PM
What project type are you using? Pure InstallScript, Basic MSI, or InstallScript MSI.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 05, 2007
08:45 AM
I use the pure InstallScript type.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 05, 2007
09:05 AM
In an InstallScript project you create\modify an environment variable by writing to the registry. So first I would use the GetEnvVar function to retrieve the current path variable. Then add your path to the string. Finally I would use RegDBSetKeyValueEx to write your path back to the registry. The following code has not been tested but will hopefully point you in the right direction.
sRegKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
GetEnvVar("PATH", svEnvVar);
sNewPath= svEnvVar + NEW_PATH_FOLDER";
nResult = RegDBSetKeyValueEx(sRegKey, "PATH", REGDB_STRING_EXPAND, sNewPath, -1);
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 06, 2007
02:19 AM
Thanks! It works very well. But I have one new problem, that every path-entry exits two times in the new PATH environment variable.
I think that the reason for this is, that an other program set also a PATH user variable and if I read the PATH variable, both variables (user and system environment variable) will be read out. So my questions: Can I tell them to read only the system variable?
Thanks, Hannes
I think that the reason for this is, that an other program set also a PATH user variable and if I read the PATH variable, both variables (user and system environment variable) will be read out. So my questions: Can I tell them to read only the system variable?
Thanks, Hannes
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 06, 2007
08:32 AM
Try parsing the path to see if the path you are adding is already there. If it is then you do not need to add your path.
Your other option is to replace the GetEnvVar with a registry read of the same key you are saving the path back to. This will ensure that you are only reading the system variable, but will not ensure that the path is not in the user's path.
Your other option is to replace the GetEnvVar with a registry read of the same key you are saving the path back to. This will ensure that you are only reading the system variable, but will not ensure that the path is not in the user's path.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 06, 2007
10:06 AM
I have a header/rul combo from InstallSite.org that does this for you. Have had great success using it. I attached it for you if you'd like to try it out.
I tried searching the site for it so you could grab it, but couldn't find it. There's another one there now (search by 'Handle PATH Environment on NT').
I tried searching the site for it so you could grab it, but couldn't find it. There's another one there now (search by 'Handle PATH Environment on NT').
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 07, 2007
02:27 AM
I use windows XP.
my code looks like:
sRegKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx(sRegKey,"PATH", nvType, sRegCurrentVal, nvSize);
This code only returns me the current installation path (TARGETDIR) and not the entry in the PATH environment variable.
Hannes
my code looks like:
sRegKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx(sRegKey,"PATH", nvType, sRegCurrentVal, nvSize);
This code only returns me the current installation path (TARGETDIR) and not the entry in the PATH environment variable.
Hannes