5.0

Table Of Contents
VMware, Inc. 73
8
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 73
“ImplementScriptsinaThinAppEnvironment”onpage 74
“A P I Functions”onpage 77
Callback Functions
Callbackfunctionscanrunundercertainconditions.For example,callbackfunctionsrunscriptcodeonly
whenanapplicationstartsorquits.
Callbackfunctionnamesincludethefollowingnames:
OnFirstSandboxOwnerCalledonlywhenanapplicationfirstlocksthesandbox.Thiscallbackisnot
calledifasecondcopyofthesameapplicationusesthesamesandboxwhilethefirstcopyruns.Ifthefirst
applicationspawnsasubprocessandquits,thesecondsubprocesslocksthesandboxandpreventsthis
callbackfromrunninguntilallsubprocessesquitandtheapplicationrunsagain.
OnFirstParentStartCalledbeforerunningaThinAppexecutablefileregardlessofwhetherthe
sandboxissimultaneouslyownedbyanothercapturedexecutablefile.
OnFirstParentExitCalledwhenthefirstparentprocessexits.Ifaparentprocessrunsachildprocess
andquits,thiscallbackiscalledevenifthechildprocesscontinuestorun.
OnLastProcessExitCalledwhenthelastprocessowningthesandboxexits.If aparentprocessrunsa
childprocessandquits,thiscallbackiscalledwhenthelastchildprocessexits.
Creating ThinApp Scripts
8