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

Enviroment Variables Replace and Append

I have an application that places a System path variable of "C:\blah_24\lib32". When I install a new version of this application I want to change the variable to "C:\blah_25\lib32". If I choose append, an entire new line will just be added to the the path. If I choose replace, the whole path will be replaced with the one new line. How can I make this change using the options provided in Admin Studio 9.5? Thanks for any help
(3) Replies
The Environment variables view in InstallShield Editor is based on the functionality in the Environment table. Here is the documentation for this table:

http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx

As you can see, unfortunately, there isn't any functionality available where you can do a find and replace on a portion of the existing environment variable value.

You could have your updated path be prepended to the beginning of the PATH environment variable and leave your original path still in there. However, this is probably not advisable because you would probably want to keep system paths at the beginning of the path and wouldn't want a situation where the new application ends up using a file in the old application path in a rare situation.

Perhaps the only solution is to implement a custom action that does the string processing necessary to remove your application's old path string from the PATH env variable. For example, you could set a MSI property using the syntax [%PATH] to get the existing value of the PATH environment variable in a property. Then you could use a VBScript/MSI DLL/.NET DLL custom action to strip out the old path from it. Then you can use the Environment Variable view to use the property to set the PATH env variable.
Thanks Ajay. Here's what I did to fix the problem. I used a custom action to run the following vbs:

Set objWshShell = CreateObject("WScript.Shell")
Set objEnvironment = objWshShell.Environment("SYSTEM")
strOriginalString = "C:\blah\blah3"
strReplacementString = "C:\blah\blah4"
strPath = objEnvironment("PATH")

strPath = Replace(strPath,strOriginalString,strReplacementString)

objEnvironment.Item("PATH") = strPath


I messed around with the placement to finally get it to work but I'm all good now.:)
Ok well, glad to hear that you have a working solution!