EasyManua.ls Logo

VMware THINAPP 4.6 - Modify the Virtual Registry; .Reg Example; Stopping a Service Example; Copying a File Example

VMware THINAPP 4.6
146 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
VMware, Inc. 117
Chapter 9 Creating ThinApp Scripts
Modify the Virtual Registry
ThefollowingscriptproceduremodifiesthevirtualregistryatruntimetoloadanexternalODBCdriverfrom
thesamedirectorywherethepackageexecutablefileislocated.
Modify the registry
1 Obtainthepathtothepackageexecutablefiles.
Origin = GetEnvironmentVariable("TS_ORIGIN")
2Findthelastslashinthepathandobtainthecharactersthatprecedetheslash.
LastSlash = InStrRev(Origin, "\")
SourcePath = Left(Origin, LastSlash)
3FormanewpathtotheODBC DLLfilelocatedoutsideofthepackage.
DriverPath=SourcePath + "tsodbc32.dll"
4Modifythevirtualregistrytopointittothislocation.
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Transoft ODBC Driver\Driver,"
DriverPath
ThismodificationcausestheapplicationtoloadtheDLLfromanexternallocation.
.reg Example
Thefollowingscriptimportstheregistryvaluesfromanexternal.regfileintothevirtualregistryatruntime.
Function OnFirstParentStart
ExecuteVirtualProcess "regedit /s C:\tmp\somereg.reg"
End Function
Stopping a Service Example
Thefollowingscriptstopsavirtualornativeservicewhenthemainapplicationquits.
Function OnFirstParentExit
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "net stop ""iPod Service"""
End Function
Copying a File Example
Thefollowingscriptsectionsshowshowtocopyaconfigurationfilelocatedinthesamedirectoryasthe
capturedexecutablefileintothevirtualfilesystemeachtimetheapplicationstarts.Thisscriptisusefulforan
externalconfigurationfilethatiseasytoeditafterdeployment.Becausethecopyoperation
occurseachtime
youruntheapplication,anychangestotheexternalversionarereflectedinthevirtualversion.
Forexample,ifyourcapturedexecutablefileisrunningfrom\\server\share\myapp.exe,thisscript
searchesforaconfigurationfilelocatedat\\server\share\config.iniandcopiesittothevirtualfile
systemlocationat
C:\Program Files\my application\config.ini.
ByputtingthiscodeintheOnFirstParentStartfunction,itisonlycalledonceeachtimethescriptruns.
Otherwiseitrunsforeverychildprocess.
Function OnFirstParentStart

Table of Contents

Related product manuals