4.7.3

Table Of Contents
ThinApp User’s Guide
74 VMware, Inc.
ThinAppsetsupTS_ORIGINtoindicatethefullpathtoacapturedexecutablefilepackage.Avirtual
applicationsetstheTS_ORIGINvariabletothephysicalpathoftheprimarydatacontainer.Ifyouhaveavirtual
applicationconsistingofthemain.exeandshortcut.exefiles,bothfilesresideinC:\VirtApp.Whenyou
runthemain.exefile,TS_ORIGIN varissettoC:\VirtApp\main.exe.Whenyouruntheshortcut.exefile,
theTS_ORIGINenvironmentvariableissettoC:\VirtApp\main.exe.Theenvironmentvariableisalwaysset
totheprimarydatacontainer,evenwhenyoucreateashortcut.WhenyourunVBScriptsthatareincludedin
thepackage,
thevariableisalreadysetandavailabletothescripts.
Origin = GetEnvironmentVariable("TS_ORIGIN")
YoucanseparatethefilenamefromTS_ORIGINbyfindingthelastbackslashandremovingallofthecharacters
followingit.
LastSlash = InStrRev(Origin, "\")
SourcePath = Left(Origin, LastSlash)
Thesourcefiletocopyintothevirtualenvironmentisthepackagepathplusconfig.ini.
SourceFile = SourcePath + "Config.ini"
ThelocationtocopytomightbeadifferentlocationondifferentcomputersiftheProgram Filesdirectoryis
mappedtoalocationotherthanC:\.ThefollowingcallletsThinAppexpandamacrotoobtainthecorrect
locationforthelocalcomputer.
DestFile = ExpandPath("%ProgramFilesDir%\MyApplication\Config.ini")
UsethefilesystemObjectparametertocheckthesourcefileexists.
Set objFSO = CreateObject("Scripting.filesystemObject")
If objFSO.FileExists(SourceFile) Then
Ifthesourcefileexists,copyitintothevirtualfilesystem.The%ProgramFilesDir%\MyApplicationvirtual
directoryisinthepackage.
objFSO.CopyFile SourceFile, DestFile, TRUE
End if
End Function
Add a Value to the System Registry
Thisscriptprocedureaddsavaluetothephysicalsystemregistry.
Add a value to the system registry
1 Createa.regfileandruntheregedit /scommandasanexternalprocessthataccessesthesystem
registryinsteadofthevirtualregistry.
Function OnFirstParentStart
2 Createthe.regfileinalocationthathastheIsolationModeparametersettoMergedsothatthevirtual
environmentcanaccessitwiththisscriptandthephysicalenvironmentcanaccessitwiththeregedit
/scommand.
RegFileName = ExpandPath("%Personal%\thin.reg")
Set fso = CreateObject("Scripting.filesystemObject")
Set RegFile = fso.CreateTextFile(RegFileName, true)
The%Personal%directoryisadirectorythathasMergedisolationmodebydefault.
3Constructthe.regfile.
RegFile.WriteLine("Windows Registry Editor Version 5.00")
RegFile.WriteBlankLines(1)
RegFile.WriteLine("[HKEY_CURRENT_USER\Software\Thinapp\demo]")
RegFile.WriteLine(chr(34) & "InventoryName" & chr(34) & "=" & chr(34) &
GetBuildOption("InventoryName") & chr(34))
RegFile.Close