4.5

Table Of Contents
ThinApp User’s Guide
106 VMware, Inc.
ThefollowingcallbackexampleshowstheOnFirstSandboxOwnerandOnFirstParentExitfunctions.
------------------------example.vbs ---------------------------------
Function OnFirstSandboxOwner
msgbox "The sandbox owner is: " + GetCurrentProcessName
End Function
Function OnFirstParentExit
msgbox "Quiting application: " + GetCurrentProcessName
End Function
msgbox "This code will execute for all parent and child processes"
---------------------------------------------------------------------
Implement Scripts in a ThinApp Environment
Youmightimplementascriptinthefollowingcircumstances:
Timingoutanapplicationonaspecificdate.
Runninga.batfilefromanetworkshareinsidethevirtualenvironment.
Modifyingthevirtualregistry.
Importingthe.regfileatruntime.
Stoppingavirtualservicewhenthemainapplicationquits.
Copyinganexternalsystemconfigurationfileintothevirtualenvironmentonstartup.
To implement a script
1 Savethescriptcontentsinaplaintextfilewiththe.vbsextensioninthesamedirectoryasyour
Package.inifile.
Youcanuseanyfilename.ThinAppaddsall.vbsfilestothepackageatbuildtime.
2Rebuildtheapplication.
.bat Example
Thefollowingscriptrunsanexternal.batfilefromanetworkshareinsideofthevirtualenvironment.
The .batfilemakesmodificationstothevirtualenvironmentbycopyingfiles,deletingfiles,orapplying
registrychangesusingregedit /s regfile.reg.Runthisscriptonlyforthefirstparentprocess.Ifyourun
thisscript
forotherprocesses,eachcopyofthecmd.exeutilityrunsthescriptandaninfiniterecursiondevelops.
Function OnFirstParentStart
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "\\jcdesk2\test\test.bat"
End Function
Timeout Example
Thefollowingscriptpreventstheuseofanapplicationafteraspecifieddate.TheVBSdateusesthe
#mm/dd/yyyy#format,regardlessoflocale.
Thischeckoccursuponstartupoftheparentprocessandanychildprocesses.
if Date >= #03/20/2007# then
msgbox "This application has expired, please contact Administrator"
ExitProcess 0
end if