Video Screencast Help
Endpoint Virtualization Community Blog

Handle Path Environment Variable in an Application Layer

Created: 19 Sep 2006 • Updated: 29 Jul 2010 • 5 comments
AngelD's picture
0 0 Votes
Login to vote

Many users on the "Software Virtualization Solution Support Forum have stated (and you may also have noticed) that the path environment variable included in an Application layer is not displayed during layer activation.

Cause
The system Path environment variable which is stored in the registry key "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" is included
in the Base (layer) by default. When an application search for an executable explorer.exe is called to resolve the Path variable (which specifies the search path for executable files). The explorer.exe resides in the Base and the Path variable in the Base will therefore be used due to SVS default priority order.

Resolution
By default there is no User Path environment variable (stored in the registry key "HKCU\Environment") defined in the Base which makes it possible to take advantage of the default priority order. When both System and User Path environment variable are specified the User Path variable value will be appended to the end of the System Path value making these two defining the Path variable. If we make sure no applications installed in the Base setting the User Path variable we can use the User Path variable in our Application layer(s) to get the result we want.

The spawned child process (explorer.exe) located outside of the Application layer will first use files & registry entries inside it's own layer (Base) and if not found it will search for existing files & registry entries in other active Application layers (apart from files located in Data layers which has the highest priority). This means, when the User Path variable is not found in the Base the User Path variable in the active Application layer will be found and used instead. If more then one Application layer includes the User Path variable the default activation and/or priority order applies.

We can both add the User Path variable using SVSAdmin or by directly modifying the Read-only sub layer for the Application layer. SVSAdmin only supports to add registry value types String, DWORD, Binary & Multi-String and the Path variable must be specified with the registry type REG_SZ or REG_EXPAND_SZ. Environment variable that is in the form that needs to be expanded (for example, %SystemDrive%) must be stored in the registry as a REG_EXPAND_SZ registry value, we will therefore add the User Path variable in the redirection area to support this form by default.

By adding the Flags (DWORD) registry entry in "HKLM\SYSTEM\Altiris\SVS" with a value of 1 SVSAdmin will display the Sublayer Info (for example, RO=1, RW=2) in the Details view (View menu -> Details) for each imported layer.

Find the Read-only (RO) Sublayer number and launch regedit.exe. Expand to the Read-only sub layer in the redirection area (for example, HKLM\SOFTWARE\fslrdr\1) and expand further down to the "HU\USER_TEMPLATE" registry key. Add the "Environment" registry key and the "Path" (REG_EXPAND_SZ / Expandable String) value with the value of "the User Path variable value" you want (for example, %ProgramFiles%\Altiris\Tools).

Any executable located in the "C:\Program Files\Altiris\Tools" directory can now be found/executed without the full path to the file from anywhere.

Comments 5 CommentsJump to latest comment

Daniel Bentsur's picture

Hi,
I love to be able to add to the path for many developer installs - but when I attempt to open HKLM\SOFTWARE\fslrdr\1\HU\USER_TEMPLATE I get the error 'Error opening key : Cannot open USER_TEMPLATE'

I'm using SVSAgent SP1 HF2 if that's any help. Oh and I'm in an Admin account on Windows XP.

Any help much appreciated.

;-Daniel

-2
Login to vote
AngelD's picture

Hi Daniel,

You will need to deactivate the layer before attempting to change anything in the Read-only sub layer. When the layer is active the filter driver (I think) locks this registry key. Really don't know why but hopefully someone on the SVS Team can explain why this happens.

+2
Login to vote
Daniel Bentsur's picture

Hi AngelD,

You were spot on. Should've guessed, but it's good to find out the community is active.

Many thanks,
;-Daniel

-2
Login to vote
dbush's picture

This looks like good info, but I'm not able to get it working for any application I've tried yet (a few.) Does anyone have this working on the 2.0.1393?

Thanks,
David

+2
Login to vote
AngelD's picture

Although SVS 2.1 Beta 2 which you can register for at the Altiris Beta Portal virtualizes the system path variable correctly, this could still be used for earlier versions.

Make sure you do not have the User Path environment variable stored in Base (the Path registry entry under "HKCU\Environment") and you should be safe.

Describe exactly what you have done and how you're verifying that it isn't working then it will be easier to help.

It may take some time for approval of replies at the Juice site so maybe for a quicker resolution try posting to the SVS Altiris Forum instead.

+2
Login to vote