Over a month ago I was in some conversations with some fellow Citrix consultants on Twitter about how they use XenAppPrep when updating provisioned XenApp servers.  There has also been some forum postings on this subject as well.  This is also a topic of conversation with customers who are testing Provisioning Services with XenApp.  In this blog post I am going to go over some XenAppPrep options when updating provisioned XenApp server images.

What is XenAppPrep?

XenAppPrep is like Sysprep for XenApp servers that are going to be provisioned with Provisioning Services.  It generalizes a XenApp server for creating a master Provisioning Services image.  XenAppPrep is installed and ran on a XenApp server before XenConvert is ran to make a Provisioning Services vDisk image.  XenAppPrep runs as a service and controls XenApp services when the XenApp server boots.   For a full description of XenAppPrep and how to use it see the Citrix knowledgebase article CTX116063 – XenAppPrep Integration Utility for XenApp and Provisioning Services.

What is the process when updating provisioned XenApp Provisioning Services vDisk Images?

I have seen several Citrix support forums postings about this and also had some conversations on Twitter about this.  There are multiple ways of doing this.

One option is to rerun XenAppPrep and the Provisioning Services Target Device Optimization Utility every time you update your master in private mode before changing it back to standard mode.  This process involves stopping the XenAppPrep service, deleting the XenAppPrep service and running XenAppPrep again.  This process can be scripted and ran each time after making updates in private mode before changing back to standard mode.  See the following example script:

REM Script by Jarian Gibson for Provisioning Services for XenApp with XenAppPrep
REM Run this script after making updates in Private Mode before shutting down and putting back into Standard Mode.
REM Make sure XenAppPrep is installed.
REM ***************************************************
REM This section will stop the XenAppPrep Service, delete the XenAppPrep service, run XenAppPrep /PVS for XenApp to get ready standard mode, and launch the Target Device Optimizer
Net Stop XenAppPrep
SC Delete XenAppPrep
REM Add /MSMQ after /PVS if using Smart Auditor XenAppPrep /PVS /MSMQ
“C:Program FilesCitrixXenAppPrepXenAppPrep.exe” /PVS
“C:Program FilesCitrixProvisioning ServicesTargetOSOptimizer.exe”
REM Server is ready to be shutdown and be put in Standard Mode
Pause
REM ***************************************************

Another option is to change the XenAppPrep service to manual startup mode, have a group policy startup script detect whether provisioned XenApp server vDisk is in standard or private mode, and start or not start the XenAppPrep service depending on the vDisk mode.  Using this option takes advantage of the personality.ini file that gets created on the root of the target device’s system drive every time it boots.  The personality.ini contains information such as target device name, write cache type, etc.  You can also add custom fields on each target device in the personality tab in the Provisioning Services console for scripting other processes.  A good example would be for pre-caching streamed applications at startup depending on which streamed applications are published to the XenApp server.  You can add personality string with a name and strings for UNC paths to each streaming profile (separated by commas) in the personality tab.  The pre-cache startup script reads the personality.ini, reads the strings for streamed application profiles, and pre-caches those streamed applications when the server boots.

For reading the vDisk mode, the personality.ini has a string called $WriteCacheType.  $WriteCacheType is equal to a number that corresponds to what mode the vDisk is in.  See the following for $WriteCacheType values.

0 =

1 through 7 = :
1 (Server Disk)
2 (Server Disk Encrypted)
3 (RAM)
4 (Hard Disk)
5 (Hard Disk Encrypted)
6 (RAM Disk)
7 (Difference Disk)

By setting the XenAppPrep service to manual and using a group policy startup script to read the personality.ini file you can control whether the XenAppPrep service starts or doesn’t start depending on the vDisk mode.  The following example script reads the personality.ini file, detects the vDisk mode to start or not start the XenAppPrep service, and writes a Windows Application Event Log entry.

@Echo off
REM Script Jarian Gibson for Provisioning Services and XenAppPrep
REM Add this script as a startup script in Group Policy.
REM Set the XenAppPrep service to manual startup.
REM ***************************************************
REM This section will check to see the PVS vDisk Mode.
REM If the PVS vDisk is in Private Mode, then the XenAppPrep service will not start.
Type C:Personality.ini | FIND /I “$WriteCacheType=0” >nul
If %errorlevel%==0 (
Echo “Warning: Private Mode vDisk – XenAppPrep Service Will Not Start”
REM Write Warning to Windows Application Event Log
eventcreate /t warning /id 100 /l application /so XenAppPrep /d “Private Mode vDisk – XenAppPrep Service will not start.”
GoTo NoXenAppPrep
)
Net Start XenAppPrep
Echo “Info: Standard Mode vDisk – XenAppPrep Service Will Start”
REM Write Info to Windows Application Event Log
eventcreate /t information /id 100 /l application /so XenAppPrep /d “Standard Mode vDisk – XenAppPrep Service will start.”
:NoXenAppPrep
REM ***************************************************

Now XenAppPrep is not your only option when using provisioned XenApp images.  Pierre Marmignon has another tool called the XenApp Cloning Tool on his site, CitrixTools.net.  His tool works for provisioned and non provisioned XenApp cloning.

Update: As of XenAppPrep 3.0.0, you no longer need to stop and delete the XenAppPrep service before running XenAppPrep /PVS after updating your provisioned XenAppPrep image to re-seal it before deploying the updated image.

As you can see you have a few options for XenAppPrep when updating provisioned XenApp images.  What are method are you using when updating provisioned XenApp images?

If you have found this article interesting or if you have any other insights, please feel free to contact me via email.