Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Eniviroment Variable


3 replies to this topic

leshon

leshon
  • Full Members
  • 3 posts

Posted 30 June 2010 - 12:31

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 replace with the one new line. How can I make this change using the options provided in Admin Studio 9.5? Thanks for any help

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 02 July 2010 - 15:56

Uninstalling the previous version (i.e. major upgrade) is not an option? This would remove the previous entry.

There are no built-in string processing functions in Windows Installer so you probabaly should sue a System Search to read the existing entry, use a custom action to change the text value of the property, and write it back using Windows Installer's standard functionality.

leshon

leshon
  • Full Members
  • 3 posts

Posted 06 July 2010 - 19:00

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.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 08 July 2010 - 09:19

If you modify the target system in a custom action you should also create actions for uninstall and rollback (in case the install fails). It would be better to only use a custom action to do the string processing and use the Environment table to let Windows Installer handle the actual system modification.