Twitter: langonej
Published Work

TECHTARGET
- * Troubleshooting VMware View Bottlenecks with VMware AppSpeed
- * How to put the VMware View client on a USB drive with VMware ThinApp
- * Using VMware RAWC to see how VMware View workloads may affect your architecture
- * Reviewing bluelock vCloud Express
- * Reviewing the five official VMware vCloud Express providers
- * 10 virtualization predictions for 2010

VIRTUALIZATION.INFO
- * The Apple iPad Opened the Door for the Real Business Tablets
- * Designing the Virtual Data Center - Part 2: Building Blocks or Bespoke Bits?
- * Designing the Virtual Data Center - Part 1
OTHER SOURCES
Additional Info
User login
Automatically Map a Drive When Launching a VMware ThinApp Package (and other trickery)
I was recently engaged with some colleagues on a large appvirt + VDI solution that involved many moving pieces, including cross-domain authentication for VMware View, zero clients with PCoIP and ThinApp in a wide array of permutations.
One of the requirements was to map a drive (e.g. V:\ which equates to \\IGIVBCFS01\Visio) when launching a VMware ThinApp package (e.g. Visio 2007) and then unmap the drive upon package exit.
For those that are unaware, VMware ThinApp is an application virtualization (appvirt) solution that allows the ability to bundle applications (with a virtual OS) for distribution to physical/virtual environments through a variety of means (streamed via a network file share, USB drive, local copy, et cetera).
In order to map a network drive during launch, the first advanced ThinApp concept to grasp is that of the Callback function.
From the VMware documentation, Callback functions with specific names run only under certain conditions. For example, callback functions run script code only when an application starts or quits."
Another piece of the ThinApp puzzle to understand is the sandbox. The sandbox is where all user data is (typically) saved. This could be a separate directory on a USB drive, a network share, a roaming profile, local destination, et cetera.
There are 4 types of Callback functions, and they are:
- OnFirstSandboxOwner
- OnFirstParentStart
- OnFirstParentExit
- OnLastProcessExit
Putting a script in this section will cause it to run when an application first launches (and locks the sandbox). This code will not run on subsequent launches that use the same sandbox.
Putting a script in this section will cause it to run regardless of whether the sandbox is simultaneously owned by instance of the launched package.
Putting a script in this section will cause it to run when the first launch of the application (parent) exits. This script will run even if a child process of the package continues to run (as the parent was initiated an exit).
Putting a script in this section will cause it to run when the last child (or only parent) of the package initiates an exit.
I used this very good base shell to work from.
' DECLARE VARIABLES
Dim WSHNetwork, WSHShell, objFSO
' SET GLOBAL VARIABLES
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' DEFINE SCRIPT ENVIRONMENT VARIABLES
Origin = GetEnvironmentVariable("TS_ORIGIN")
LastSlash = InStrRev(Origin, "\")
SourcePath = Left(Origin, LastSlash)
ExeName = Mid(Origin, LastSlash + 1, Len(Origin))
Function OnFirstSandboxOwner
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "V:", "\\10.10.20.32\Visios"
End Function
Function OnFirstParentStart
'This launches ONCE for each entry point within the ThinApp packaged application.
End Function
Function OnFirstParentExit
'This launches ONLY ONCE at the point when the 1st entry point (who locked the sandbox) exits. This does not unlock the sandbox.
Set objNetwork = CreateObject("WScript.Network")
objNetwork.RemoveNetworkDrive "V:", True, True
End Function
Function OnLastProcessExit
'This launches ONLY ONCE for the very last process (not entry point) that exits from within the ThinApp packaged application, shutting down the virtual OS.
End Function
Save the above file as a .vbs file (e.g. visio.vbs). Should you have a script that's not VBS, you could always call it from this script. For ThinApp, the initial script MUST BE a .vbs.
Now that you have your .vbs file, build your package. This is done by taking a PRE scan of a desktop (preferably a clean VM), then installing the application, then taking a POST scan. This will then generate a directory of files for the BUILD.
Simply place your .vbs (e.g. visio.vbs) in the \BUILD directory and run the build.bat file. Viola!, your ThinApp package now has the .vbs file and will map the V:\ drive upon launch (and unmap upon exit).
More ThinApp goodness to come.
- Add new comment
- 875 reads
Accolades






Video
"Green IT" - Leveraging VMware to provide a green datacenter.
Preview of the upcoming VMware View iPad App with PCoIP support.
Ubertechnik 350Z at VIR.
Latest from Disqus
Consulting Gigs
CURRENT GIGS for 1099 VCP's
- * VMware Site Recovery Manager Consultant.
Status: FILLED.
Duration: 3 WeeksLocation: Reston, VA
Clearance: None
- * Senior Solaris Consultant.
Duration: 3+ Weeks
Location: Reston, VA
Clearance: TS SCI
Note: All 1099 consultants must be a current VCP.
