Hello,
I try to install a component dependend on the value of an environment variable. The syntax used for this purpose may be the problem, because the condition allways evaluates TRUE:
Condition: "%TEST=XYZ"
Alternatively I tried to use a CA 51:
Action: GetTESTValue
Source: TEST
Target: [%TEST]
Execution Scheduling: Allways execute
Install UI Sequence: <First Action>
Install Exec Sequence: <First Action>
So can anyone tell me what went wrong?
Thanks
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.
Env Var Condition
Started by
aspring
, Jun 10 2003 15:52
8 replies to this topic
Posted 10 June 2003 - 23:18
1. You forgot the double quotes
2. Windows Installer is too stupid to tell you.
2. Windows Installer is too stupid to tell you.
---
Dennis Bareis (dbareis@No.Spam.gmail.com)
Free MSI update/creation tool (MAKEMSI):
http://users.cyberon...eis/makemsi.htm
Dennis Bareis (dbareis@No.Spam.gmail.com)
Free MSI update/creation tool (MAKEMSI):
http://users.cyberon...eis/makemsi.htm
Posted 11 June 2003 - 07:14
I changed the line to:
Condition: %TEST="XYZ"
To be sure, I checked the value of TEST through the output of a MessageBox, after fetching the variable with GetEnvVar. This seemed to be fine, but the condition still evaluates to FALSE.
Placing the entire expression in double quotes
Condition: "%TEST=XYZ"
allways evaluates to TRUE. It seems, that every string evaluates to TRUE, regardless of it's content.
Do I need the CA 51? There's no difference even with or without it.
I also tried to use a property
Name: TEST
Value: [%TEST]
but this was unsuccessfull too.
Thanks for your suggestions
Condition: %TEST="XYZ"
To be sure, I checked the value of TEST through the output of a MessageBox, after fetching the variable with GetEnvVar. This seemed to be fine, but the condition still evaluates to FALSE.
Placing the entire expression in double quotes
Condition: "%TEST=XYZ"
allways evaluates to TRUE. It seems, that every string evaluates to TRUE, regardless of it's content.
Do I need the CA 51? There's no difference even with or without it.
I also tried to use a property
Name: TEST
Value: [%TEST]
but this was unsuccessfull too.
Thanks for your suggestions
Posted 11 June 2003 - 08:47
Try a case insensitive test, eg.
%TEST~="XYZ"
Further, the condition "~Test=XYZ" is indeed a text. Every non-empty text is considered True. You shouldn't need a CA51, just to copy the environment variable in a property. But for testing purposes, your CA is fine. Change the condition in
TEST~="XYZ"
Are you sure that the environment variable is there? Try a well known variable, like PATH or TEMP.
%TEST~="XYZ"
Further, the condition "~Test=XYZ" is indeed a text. Every non-empty text is considered True. You shouldn't need a CA51, just to copy the environment variable in a property. But for testing purposes, your CA is fine. Change the condition in
TEST~="XYZ"
Are you sure that the environment variable is there? Try a well known variable, like PATH or TEMP.
Posted 11 June 2003 - 12:54
Hi,
now I've made some progress with these environment vars. When using TEMP everything works well!
So it seems to me, that there's a difference between my temporary vars and system vars.
I used following command:
> set TEST=XYZ
and checked success with
> set TEST
Then I used GetEnvVar in the InstallScript function OnBegin() to read this variable and showed the value in a MessageBox. There's no evidence for an error - everything behaved as expected.
Does anyone know how to get arround this problem?
Thank you
now I've made some progress with these environment vars. When using TEMP everything works well!
So it seems to me, that there's a difference between my temporary vars and system vars.
I used following command:
> set TEST=XYZ
and checked success with
> set TEST
Then I used GetEnvVar in the InstallScript function OnBegin() to read this variable and showed the value in a MessageBox. There's no evidence for an error - everything behaved as expected.
Does anyone know how to get arround this problem?
Thank you
Posted 12 June 2003 - 00:38
Where and when are you setting this environment variable? It may not be visible to your setup.
Stefan Krüger
InstallSite.org twitter facebook
Posted 12 June 2003 - 06:57
I've set the variable in a command line window before starting setup.exe. For me it's surprising, why the value can be retrieved with GetEnvVar(), while it's not available to the condition.
Is it possible to get an error message from Windows Installer, if it encounters a problem with a condition or somthing else?
Is it possible to get an error message from Windows Installer, if it encounters a problem with a condition or somthing else?
Posted 12 June 2003 - 08:16
I'm not sure but I think what is happening here is: the environemnt variable you are setting only exists in the process in which you are setting it, and it's child processes (including the UI part of your installation). But it will not be visible to processes that started earlier. Now on NT/2000/XP the Execute sequence runs in a aprt of Windows Installer that runs as system service, i.e. it starts when the OS is booted. So you may need to set the environment variable earlier, or at least publish a message that the environment has changed so that running processes update their settings.
Stefan Krüger
InstallSite.org twitter facebook
Posted 16 June 2003 - 13:51
Assuming you use NT/2000XP, my guess is a mixup between User variables and System variables. When you open a command prompt, and execute
SET TEST=XYZ
this variable becomes available to every process started from the command prompt, that is executed by the same user (no impersonation). In case of the Windows Installer, a big part is executed by the Installer service, that uses an account of LOCALSYSTEM.
Further, any process started otherwise doesn't have this variable.
A better approach would be changing the environment variables the official way:
Ask the properties of My Computer, tab Advanced, button Environment Variables. You can set both User variables and System Variables. Anything you set here, will persist over reboots, logons etc.
SET TEST=XYZ
this variable becomes available to every process started from the command prompt, that is executed by the same user (no impersonation). In case of the Windows Installer, a big part is executed by the Installer service, that uses an account of LOCALSYSTEM.
Further, any process started otherwise doesn't have this variable.
A better approach would be changing the environment variables the official way:
Ask the properties of My Computer, tab Advanced, button Environment Variables. You can set both User variables and System Variables. Anything you set here, will persist over reboots, logons etc.