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.
- Flexera Community
- :
- AdminStudio
- :
- AdminStudio Forum
- :
- Re: Enviroment Variables Replace and Append
Subscribe
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 30, 2010
06:44 AM
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
This thread has been automatically locked due to inactivity.
To continue the discussion, please start a new thread.
3 Replies
- Mark as New
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 01, 2010
12:49 PM
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.
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.
- Mark as New
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 06, 2010
01:00 PM
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.:)
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.:)
- Mark as New
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 06, 2010
03:13 PM
Ok well, glad to hear that you have a working solution!
