[wpkg-users] Assigning a Variable from a Registry key
Rainer Meier
r.meier at wpkg.org
Wed Sep 5 15:32:16 CEST 2012
Hi Malte,
On 05.09.2012 13:00, Malte Hohmann wrote:
> I am not sure if WPKG updates the environment at all. It saves and restores its
> environment during processing of any package - at least this is logged in the
> output - so I think it just stores its environment variables somewhere and
> reloads them, ignoring any changes done to the system environment. However, I
> did not check this in the source code as I have no clue about JScript. Maybe
> Rainer could shed some light into this...
WPKG saves its environment into internal data structure. Each time variables are
loaded a snapshot of the environment is made, then WPKG defines the variable and
afterwards it reverts to previous state.
For example if a package defines variables then WPKG takes a snapshot of the
environment before the package is applied. Then it sets the variables, executes
commands and reverts to the snapshot.
As the whole WPKG execution phase takes place within a single cscript
environment it will not pick up variables defined with setx or any other tools.
Actually it cannot do this and no process is doing this. Even "setx /m" will not
"inject" new variables into existing processes environment. You can easily prove
this opening 2 admin shells, then execute "setx /m VAR test" in one windows and
then executing "echo %VAR%" in the other. The second window will not know about
the variable %VAR%.
Of course when you fork a new process (open a third cmd window) it will
immediately know %VAR%.
The same applies to WPKG. If you use "setx /m" within WPKG commands then this
environment is not propagated to other existing processes, including WPKG
(cscript.exe). But of course if WPKG comes across a command using "setx /m" then
all variables set here will apply to processes forked later by cscript. For
example all commands executed after the command doing setx will know the
variable (but not WPKG itself).
I am unaware about any possibility to inject variables into existing process
from JScript. Reading registry keys and setting the environment is quite an
inefficient way of doing it and actually.
So variables defined by setx /m will be available to all commands executed
afterwards but not to WPKG during execution (but on next execution they will).
br,
Rainer
More information about the wpkg-users
mailing list