Visibility of environment variable
Updated: 29 Jul 2010 | 9 comments
Hello,
I would like to virtualise an environment variable with a layer wich is hide from the system.
Then to see I launch the command svscmd "my layer" exec -p cmd.exe -nowait after activating the layer.
The problem is that I can't see my environment variable in that context by tipping set my variable.
Ps : the attached file contains an example. (rename the zip file in vsa)
discussion Filed Under:
Comments
Environment variables
Setting an environment variable within a process will only change the environment seen by that process - all other processes will continue to show the cached environment that is loaded at boot up.
In order to update the environment so that all windows see the change, it is necessary to send a message to all windows via an API call, which causes the windows to reload the environment.
This is the reason for your command window not showing the env change, I believe.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
You're correct EdT. This is
You're correct EdT. This is something that still to this day throws me though loops unless I take a minute to think about it.
If a forum post solves your problem please flag is as the solution
Thank's for your answers.
So If i anderstand your explanation , the process svscmd "my layer" exec -p cmd.exe -nowait should be able to see the new value of the environnment variable as it 's launch after activation of the layer (which set this new value).
In summary :
1 - The layer (wich is hide from the base) is activate => the new value of the environnment variable is setting
2 - The process cmd is launching (on the layer) => the new value should be seen by the set command.
The fact is that if you make this opération without hiding the layer from the base the value setting process works if you launch the cmd command after activating the layer.
I was thinking that my problem could be deal with the fact to hide it even if you launch the cmd process in it.
Other test
I made the following tests :
Test 1
1 - The layer (wich is hide from the base) is activate
2 - Lauchning the command svscmd "environnement" exec -p regedit.exe
=> I can see the new environnement variables on HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Test 2
1 - The layer (wich is hide from the base) is activate
2 - Lauchning the command svscmd "environnement" exec -p c:\setting.bat <=> (with simple commands set and pause)
=> I can't see the new environnement variables
Any idea?
How are you checking the env variables?
In test 1 - you can see the new environment variables in the registry, because the registry has been updated. HOWEVER, can you see the environment variable in your actual application's environment. The reason I ask is that simply updating the registry will not update the cached environment stored by the operating system, and I frankly don't know whether the svscmd program forces a windows reload of the new environment after the registry has been updated.
In test 2 - where are you looking for the environment change? If you run the batch file using set, the environment in that CMD session will be updated, but any other window or process will be unaware of the change. As soon as your CMD window closes, the environment change is lost, so opening another CMD window will not reveal any new environment settings.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
To answer your questions :
To answer your questions :
So to summury my tests :
a) If you don't hide a layer from the system whitch update an environnement variable, all process can see it after if you launch process after activation.
b) if you hide a layer from a system whitch update an environnement variable, no process can see it even if you launch it after activation and even if this process is in or our outside the layer .
So don't you know that we should have the same behavior on the two options (hide or not the layer)?
I mean that if you update or set a environnement variable on a layer it could be possible for process to see it if they are lauched with the rigths conditions?
Interesting scenario
In summary therefore, you are finding that if you run a hidden layer which updates the environment, the environment change is not visible to ANY process whether running in the layer or outside the layer.
Perhaps the solution is to use your hidden process to start another process in a layer that is not hidden, which updates the environment.
I do not think is it technically possible to set a system environment variable that only affects the hidden layer.
However, what I have not asked you yet, is whether you have tried setting a USER environment variable rather than a SYSTEM environment variable?
A user environment variable is specific to the current user, and appears in the HKCU registry hive under HKCU/Environment - you should find the current keys include settings for TEMP and TMP, pointing to the user profile's temp folder locations.
I have not experimented with user environment settings within SVS and don't therefore know whether these are handled correctly when the layer is activated, but it should not take long to test this.
If that does not solve your problem, perhaps Jordan could look at this further and determine whether a future release of the SVS client should be updated to handle this scenario better.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
unfortunately not
Thank's for your what you suggest but unfortunately, the two ways that you suggest can't occured my problem.
One of the reasons that we use SWV is because we can create "custom" environnment for each applications that use same variable but with differents values (with a lot of combination). For example ORCALE applications with several versions of the client on the same machine.
For the first way that you suggest, we actually do it with batch files and without virtualisation.
For the second way, the behavior is the same.
So is it a "bug"?
Do you think that i should create a Case at the support?
Open a case
Yes - unless anyone else can suggest anything I've missed, then the quickest way to move forward now is to open a case with Support.
However, I am not sure I understand why using a "user" environment setting would not work for your environment. Since the registry settings are specific to each layer, it should not make any difference from the perspective of application functionality. But of course, you understand your environment much better than I can.
Please let us know if a solution emerges from support.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Would you like to reply?
Login or Register to post your comment.