sabonis
Posts: 3
Joined: Mon Mar 17, 2008 5:56 pm

environment variables problem

My program needs an environment variable. I set the the environment variable with advanced installer and I can see the variable from windows xp and the program runs correctly if I launch it from shortcut on desktop.
Instead if I launch the program at the end of the install process (using "launch your application" check box), the program can't see the environment variable even if windows can see the variable in the same time.
gabriel
Posts: 15
Joined: Mon Mar 17, 2008 3:39 pm
Location: Craiova
Contact: Yahoo Messenger

Hi,

The environment variable you created is set, but it can not be accessed by the installation.

All environment variables created during the execution of a process are available only after the process is terminated.

This question has been answered before here :
http://www.advancedinstaller.com/forums ... t+variable

Regards,

Ovidiu Blejdea
Advanced Installer Team
http://www.advancedinstaller.com
sabonis
Posts: 3
Joined: Mon Mar 17, 2008 5:56 pm

Is there any trick to getting around this problem?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

The workaround for this limitation is to use another MSI package which creates the environment variable as a prerequisite for the main package.

Here are the steps you can take:
- create a new Advanced Installer project and configure it to create only your environment variable
- go to the "Registry" page and create a registry entry (this will be used to detect if the prerequisite was installed)
http://www.advancedinstaller.com/user-g ... istry.html
- go to the "Install Parameters" page and set the "Limit to basic user interface (simple progress and error handling)" option (to make the prerequisite installation silent)
- go to the "Product Details" page and select the "Do not show in list" option (so the user doesn't uninstall it by accident)
- create the main installation package
- go to the "Software Prerequisites" tab of the "Prerequisites" page and add the first MSI as a prerequisite
http://www.advancedinstaller.com/user-g ... requisites
http://www.advancedinstaller.com/user-g ... tware.html
- for the prerequisite you can use the registry entry in the first package as a detection criteria
http://www.advancedinstaller.com/user-g ... earch.html
- in the "Bootstrapper UI" section of the "Software Prerequisites" tab set the "UI Level" combo to "Basic UI and progress" (so the prerequisite is installed with no user interaction)
- in the "Bootstrapper" tab of the "Media" page you can include the install files in the EXE botstrapper (this is optional)
- go to the "Search" page and create a new File search for msiexec.exe
http://www.advancedinstaller.com/user-guide/search.html
- rename the search to MSIEXEC (the name of the search is actually a public property which will contain the search result)
- right-click the search and use the "Add Location" menu to add [SystemFolder] as the search location
- go to the "Custom Actions" page and show the "InstallFinalize" standard action (you can use the "Show standard action" button on the toolbar)
- under "InstallExecuteSequence" -> "InstallFinalize" create a "Property Source" custom action
http://www.advancedinstaller.com/user-g ... -page.html
http://www.advancedinstaller.com/user-g ... rty-source
- use these settings:

Code: Select all

Property Name: MSIEXEC (the property of the search)
Command Line: /x GUID /qb 
Execution Properties: Asynchronous execution, do not wait for return
Expression: (REMOVE="ALL")
- GUID is the Product Code of the first package (the one which creates the environment variable); you can get it by opening the AIP of the first package with a text editor (the "Product Code" property)

Let me know if you encounter any problems.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
liorbk
Posts: 13
Joined: Tue Apr 08, 2008 2:44 pm

Re: environment variables problem

This solution has some problems:
For start, if the software is uninstalled. the prerequisite isn't and then on the next insalltion the environment variable will not set.
If the evnironment variable is the PATH, and if it depends on the APPDIR, that we have a problem....

Can't you launch the application using schedualing in windows? That way it will start from the updated environment.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: environment variables problem

Hi,
For start, if the software is uninstalled. the prerequisite isn't
Please note that in the instructions contained by my previous post I mentioned a custom action which runs MSIEXEC with the /x parameter. This custom action uses the Product Code of the prerequisite package to uninstall the prerequisite when the main package is uninstalled.
Can't you launch the application using schedualing in windows?
I'm not sure I understand what you mean. Can you please give me more details about this?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”