Friday, 30 November 2012

Citrix XenApp Publishing Windows Explorer

We are in the process of upgrading our Citrix farm from XenApp 5 on Windows 2003 to XenApp 6.5.  One of our requirements was to publish a seemless windows version of Explorer.  In Windows 2003 this was easy, but since Microsoft decoupled explorer from IE and now whenever explorer.exe is called, the launched instance now exits and opens a new instance two problems occur.

1. The XenApp AppCenter does not think the launched application is working anymore so you do not see information under connected users

2. As soon as the session starts, it closes down again unless another process is holding it open!

There are many solutions to this availble, but none quite did the trick for me as all the ones I tried had limitations.

With a combination of a batch file, sleep.exe and hstart.exe I was able to not only get the session to stay alive while explorer was running, but also show the correct info in the AppCenter and logoff correctly when explorer was closed.

The published application should look like this:

%path%\hstart64.exe /NOCONSOLE %path%\ExplorerStart.bat

The batch file looks like this:

@echo off
ECHO Starting explorer
ECHO Checking for explorer.exe
TASKLIST /FI "USERNAME eq %userdomain%\%username%" /FI "Imagename eq explorer.exe" > %temp%\explorercheck.txt
ECHO Sleeping for 30 seconds
%path%\sleep.exe 30
set folder=%temp%\explorercheck.txt
for /f "eol=: tokens=3 delims= " %%a in ('find "explorer.exe" %folder%') do (

ECHO Explorer not found so deleting text file and exiting
del  %temp%\explorercheck.txt

I imagine there are more elegant ways of writing the batch file, but this works nicely for me.

%path% needs to be substituted for a real path in three locations.

Hope this saves someone a bit of time.