Wilco van Bragt - LinkeIn Wilco van Bragt - Twitter rssa 

Preload all application using a App-V Streaming Only infrastructure


With the introduction of App-V 4.5 product (together with renaming the SoftGrid product) several deployment scenarios where introduced. Before App-V 4.5 the components needed for SoftGrid were a database, a web server and a management console. With the client configured to connect to a SoftGrid server, the client knows all available applications in the application virtualization infrastructure. With this solution (which is still available within App-V 4.5/4.6) you could easily use the sfttray /loadall to preload all applications. However with the new deployment scenarios like the Streaming Only features this will not function anymore, because the client does not know which applications are available. In this article I will describe how you can accomplish how all application can be preloaded using a Streaming Only infrastructure.

The Situation

Because there is no application management anymore within the Streaming Only scenario both the server (there is not management part in this scenario) and the client don't know which applications are available. So the first step is to determine which applications are available within the App-V infrastructure. The applications are stored in the content folder, so we need to determine which applications are stored in this share. The second step is to preload the determined applications one by one using the available command line options available within the App-V client. The third and last step is to ensure that the preload process runs smoothly. During building and testing this preload solution I found out that when too many sfttray /load commands where run at once, the preload took much longer then when just a few applications were preloaded at once. So the solution should arrange that not too much preloads are running at the same moment.

The Solution

With the situation in mind I build a CMD script arranging the steps described in the situation paragraph.

The SFTTRAY command need to be provided with the app name as only required parameter. This app name parameter can be the actual application (as specified within the ODS file) or the name of the OSD file. While determine the actual application name is a bit more complicated than determine the OSD file, I decided to use the OSD files to preload command. Determine the available OSD files is pretty easy using the simple dir command using the parameters /s and /b.  The /s parameter arranges that all subdirectories are search and the /b parameter will take care that no additional information is displayed as a result. Combining this with a dir search on *.OSD and parsing the results of the command in a file we have all available applications in the App-V infrastructure.

The next part is to read out the results in the file and take care that every OSD file will be filled in as parameter for the SFTTRAY command.  Using the FOR command the file will be read out and every OSD file will be parsed to the SFTTRAY command.

To arrange that too much preload will be running the same time I build a simple counter component that will be raised with every time the sfttray command is started. When the counter reaches the predefined value it will wait for 20 seconds, defined using the ping localhost -n 20 command. Logically the counter will be reset to zero again, so the next five applications can be preloaded after the wait moment.

To ensure that newly added applications are preloaded I decided together with the customer that the script will run every time the system will be started using the start-up script option available in the Windows Scheduled Tasks component.

In previous version (before App-V 4.6) this was pretty not easy because the user running the scheduled task should have a full profile available on the system, but this is apparently changed within App-V 4.6 where the command runs smoothly without a full profile available (read: we did not have this behavior noticed in this new App-V 4.6 infrastructure).

When I implemented a similar script at another customer also using a scheduled task, no preloading was taking place. When I started the script with the same user with that user logged in everything was running fine. I investigated the differences between the environments (Streaming Only versus Full Infrastructure) and settings. The problem is caused by changing the default User Data location. When that path is set to a network directory (drive letter), the sfttray /load command does not function. I guess the cause is that the user is not fully logged in and the mapping is not made or the information is not read out of Active Directory. To solve the issue I added to the script to change the User Data Registry Key (located at HKLM\Software\Microsoft\Softgrid\4.5\Client\Configuration) at the beginning of the script to "%APPDATA%" and change it back to the network path at the end. Logically this implies that no users should be able to logon to the system otherwise their settings are not retained. The registry change is reflected immediately, so now restart of services is required. With this addition the script now also works at this customer.

The script

Below you will find the full script, which arranges the preload of all available App-V virtualized applications. I know that if one SFT file is accessed using several OSD files, those OSD files will all be started while the first OSD already preloaded the application into the cache. Because this is not causing any errors, the extra sfttray commands don't take much time and the customer for which I created this script does not have SFT files with multiple OSD files I did not build a solution for that situation.

You can use it and adjust to your needs, it's just provided with no warranty. I appreciate if you mention the original creator of the script and that you provide your adjustment as a comment to this article.



** Script                 : PreloadAppV.cmd
** Author              : Wilco van Bragt
** Creation Date : 23-04-2010
** Usage               : Preload all applications based on available OSD files
** Date                        Version      Scripter                Changes
** -------------------------------------------------------------------------------------
** 11:20 23-04-2010       0.1          WvB                      Initial version

:: --------------------------------------------------------------------------------------
::             Defining variables
:: --------------------------------------------------------------------------------------

setlocal enabledelayedexpansion

set /a counter=0

SET CONTENTLOCATION=\\<<SERVER>>\<<contentshare>>

:: --------------------------------------------------------------------------------------
::             Determine all available OSD and store those in a textfile
:: --------------------------------------------------------------------------------------



:: --------------------------------------------------------------------------------------
::             Read all the OSD files out of the text file and parse those to :PRELOAD
:: --------------------------------------------------------------------------------------

FOR /F "delims= tokens=1" %%i in (D:\OSDFILES.TXT) do call :PRELOAD %%i

del D:\osdfiles.txt


:: --------------------------------------------------------------------------------------
::             Preload the OSD files in bundles of five and wait 20 seconds for the next group
:: --------------------------------------------------------------------------------------


                SET OSDPRELOAD=%1

                set /a counter+=1

                START sfttray /quiet /load "%OSDPRELOAD%"

                 IF %COUNTER%==5 PING localhost -n 20&SET COUNTER==0

                 GOTO :EOF



When using a Streaming Only App-V Infrastructure you can use the sfttray /loadall command to preload all virtualized applications anymore. In this article I described how this functionality can be arranged using some scripting command to determine which applications are available and automated preloaded using the sfttray commend per OSD file.