4.0.4

Table Of Contents
ThinApp User’s Guide
110 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.
To add a value to the system registry
1 Createa.regfileandruntheregedit /scommandasanexternalprocessthataccessesthesystem
registryinsteadofthevirtualregistry.
Function OnFirstParentStart
2 Createthe.regfileinalocationthathastheIsolationModeparametersettoMergedsothatthevirtual
environmentcanaccessitwiththisscriptandthephysicalenvironmentcanitwiththeregedit /s
command.
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) and
"InventoryName" and chr(34) and "=" and chr(34) and GetBuildOption("InventoryName") and
chr(34))
RegFile.Close