[wpkg-users] Env variables within WPKG vars in <check /> statements do not resolve

Pendl Stefan stefan.pendl at haidlmair.at
Tue Jun 9 22:02:33 CEST 2009


Chris Allen wrote:
>>
<variable name='cygroot' value='%SYSTEMDRIVE%\cygwin' />
<check type="file" condition="exists" path="%cygroot%\Cygwin.bat" />
The problem appears only when using nested variables.  These examples work fine:

<variable name='cygroot' value='C:\cygwin\cygwin' />
<check type="file" condition="exists" path="%cygroot%\Cygwin.bat" />

Or:

<check type="file" condition="exists" path="%SYSTEMDRIVE%\cygwin\Cygwin.bat" />
<<
---------------------------------------------------------
Allen,
         I don't think that variable values are parsed with ExpandEnvironmentStrings.

function checkCondition does use checkPath=shell.ExpandEnvironmentStrings(checkPath); to resolve environment variables in the value.

You may change the getvariable function as follows and check if it works:

!!! this is for WPKG server 1.1.0 !!!

// --- code start (watch for line wraps)
function getVariables(XMLNode, dictionary) {
 // a new empty array of variables
 var variables;
 // make sure variables is either created or assigned
 if(dictionary == null) {
  variables = new ActiveXObject("Scripting.Dictionary");
 } else {
  variables = dictionary;
 }
 var variableNodes = XMLNode.selectNodes("variable");
 for (var i=0; i < variableNodes.length; i++) {
  var variableName = variableNodes[i].getAttribute("name");
  var variableValue = variableNodes[i].getAttribute("value");



// --- insert this

var shell = new ActiveXObject("WScript.Shell");
  variableValue = shell.ExpandEnvironmentStrings(variableValue);

// --- end insert

  dinfo("Got variable '" + variableName + "' of value '" + variableValue + "'");
  variables.Add(variableName, variableValue);
 }
 return variables;
}
// --- code end

---
Stefan




More information about the wpkg-users mailing list