4.6.1

Table Of Contents
VMware, Inc. 115
9
Scriptsmodifythebehaviorofvirtualapplicationsdynamically.Youcancreatecustomcodebeforestartingan
applicationpackagedwithThinApporafteranapplicationexits.Youcanusescriptstoauthenticateusersand
loadconfigurationfilesfromaphysicaltovirtualenvironment.
Callbackfunctionsruncodeduringspecificevents.Ifapplicationscreatech
ildprocesses,usecallback
functionstoruncodeonlyinthemainparentprocess.
APIfunctionsrunThinAppfunctionsandinteractwiththeThinAppruntime.APIfunctionscanauthenticate
usersandpreventthestartofapplicationsforunauthorizedusers.
AddingscriptstoyourapplicationinvolvescreatinganANSItextfilewiththe.v
bsfileextensionintheroot
applicationprojectdirectory.TherootprojectdirectoryisthesamedirectorythatcontainsthePackage.ini
file.Duringthebuildprocess,ThinAppaddsthescriptfilestotheexecutablefileandrunseachofthescript
filesatruntime.
ThinAppusesVBScripttorunscriptfiles.Forinform
ationaboutVBScript,seetheMicrosoftVBScript
documentation.YoucanuseVBScripttoaccessCOMcontrolsregisteredonthehostsystemorwithinthe
virtualpackage.
N
OTEYoucannotusewscript.<command>callsinThinAppVBScript.Forexample,
wscript.CreateObjectorwscript.Sleepwillgenerateerrors.
Thisinformationincludesthefollowingtopics:
“CallbackFunctions”onpage 115
“ImplementScriptsinaThinAppEnvironment”onpage 116
“A P I Functions”onpage 119
Callback Functions
Callbackfunctionscanrunundercertainconditions.For example,callbackfunctionsrunscriptcodeonly
whenanapplicationstartsorquits.
Callbackfunctionnamesincludethefollowingnames:
OnFirstSandboxOwnerCalledonlywhenanapplicationfirstlocksthesandbox.Thiscallbackisnot
calledifasecondcopyofthesameapplicationusesthesamesandboxwhilethefirstcopyruns.Ifthefirst
applicationspawnsasubprocessandquits,thesecondsubprocesslocksthesandboxandpreventsthis
cal
lbackfromrunninguntilallsubprocessesquitandtheapplicationrunsagain.
OnFirstParentStartCalledbeforerunningaThinAppexecutablefileregardlessofwhetherthe
sandboxissimutaneouslyownedbyanothercapturedexecutablefile.
OnFirstParentExitCalledwhenthefirstparentprocessexits.Ifaparentprocessrunsachildprocess
andquits,thiscallbackiscalledevenifthechildprocesscontinuestorun.
Creating ThinApp Scripts
9