4.6

Table Of Contents
ThinApp User’s Guide
116 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.
Implement a script
1 Savethescriptcontentsinaplaintextfilewiththe.vbsextensioninthesamedirectoryasyour
Package.inifile.
Youcanuseanyfilename.ThinAppaddsall.vbsfilestothepackageatbuildtime.
2Rebuildtheapplication.
.bat Example
Thefollowingscriptrunsanexternal.batfilefrom anetworkshareinsidethevirtualenvironment.The .bat
filemakesmodificationstothevirtualenvironmentbycopyingfiles,deletingfiles,orapplyingregistry
changesusingregedit /s regfile.reg.Runthisscriptonlyforthefirstparentprocess.Ifyourunthisscript
for
otherprocesses,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