4.5

Table Of Contents
VMware, Inc. 105
9
Scriptsmodifythebehaviorofvirtualapplicationsdynamically.Youcancreatecustomcodebeforestartingan
applicationpackagedwithThinApporafteranapplicationexits.Youcanusescriptstoauthenticateusersand
loadconfigurationfilesfromaphysicaltovirtualenvironment.
Callbackfunctionsruncodeduringspecificevents.Ifapplications
createchildprocesses,usecallback
functionstoruncodeonlyinthemainparentprocess.
APIfunctionsrunThinAppfunctionsandinteractwiththeThinAppruntime.APIfunctionscanauthenticate
usersandpreventthestartofapplicationsforunauthorizedusers.
AddingscriptstoyourapplicationinvolvescreatinganANSItextfilewith
the.vbsfileextensionintheroot
applicationprojectdirectory.TherootprojectdirectoryisthesamedirectorythatcontainsthePackage.ini
file.Duringthebuildprocess,ThinAppaddsthescriptfilestotheexecutablefileandrunseachofthescript
filesatruntime.
ThinAppusesVBScripttorunscript
files.ForinformationaboutVBScript,seetheMicrosoftVBScript
documentation.YoucanuseVBScripttoaccessCOMcontrolsregisteredonthehostsystemorwithinthe
virtualpackage.
Thisinformationincludesthefollowingtopics:
“CallbackFunctions”onpage 105
“ImplementScriptsinaThinAppEnvironment”onpage 106
“A P I Functions”onpage 109
Callback Functions
Callbackfunctionscanrunundercertainconditions.For example,callbackfunctionsrunscriptcodeonly
whenanapplicationstartsorquits.
Callbackfunctionnamesincludethefollowingnames:
OnFirstSandboxOwner—Calledonlywhenanapplicationfirstlocksthesandbox.Thiscallbackisnot
calledifasecondcopyofthesameapplicationusesthesamesandboxwhilethefirstcopyruns.Ifthefirst
applicationspawnsasubprocessandquits,thesecondsubprocesslocksthesandboxandpreventsthis
callback
fromrunninguntilallsubprocessesquitandtheapplicationrunsagain.
OnFirstParentStart—CalledbeforerunningaThinAppexecutablefileregardlessofwhetherthe
sandboxissimutaneouslyownedbyanothercapturedexecutablefile.
OnFirstParentExit—Calledwhenthefirstparentprocessexits.Ifaparentprocessrunsachildprocess
andquits,thiscallbackiscalledevenifthechildprocesscontinuestorun.
OnLastProcessExit—Calledwhenthelastprocessowningthesandboxexits.If aparentprocessrunsa
childprocessandquits,thiscallbackiscalledwhenthelastchildprocessexits.
Creating ThinApp Scripts
9