API Functions
You can use API functions that instruct ThinApp to complete operations such as load DLLs as virtual DLLs, convert paths from macro format to system format, and run commands inside of the virtual environment.
AddForcedVirtualLoadPath
The AddForcedVirtualLoadPath(Path) function instructs ThinApp to load all DLLs from the specified path as virtual DLLs even if they are not located in the package.
Use this function if the application needs to load external DLLs that depend on DLLs located inside the package.
You can use the ForcedVirtualLoadPaths parameter in the Package.ini file to achieve the same result as this API function. For more information about “ForcedVirtualLoadPaths” see ThinApp Package.ini Paramer Reference Gudie.
Parameters
Path
[in] The filename or path for DLLs to load as virtual.
Examples
You can load any DLL located in the same directory as the executable file as a virtual DLL.
Origin = GetEnvironmentVariable("TS_ORIGIN")
TS_ORIGIN is the path from which the executable file is running.
You can delete the filename from TS_ORIGIN by finding the last backslash and removing all of the characters that follow it.
LastSlash = InStrRev(Origin, "\")
SourcePath = Left(Origin, LastSlash)
You can instruct ThinApp to load all DLLs in the same or lower directory from where the source executable file resides.
AddForcedVirtualLoadPath(SourcePath)
This process enables you to drop additional files in the SourcePath tree and have them resolve import operations against virtual DLLs.
ExitProcess
The ExitProcessExitCode function quits the current process and sets the specified error code.
Parameters
ExitCode
[in] The error code to set. This information might be available to a parent process. A value of 0 indicates no error.
Examples
You can exit the process and indicate success.
ExitProcess 0
When the process exits, the scripting system receives its OnLastProcessExist function callback. Any loaded DLLs run termination code to clean up the environment.
ExpandPath
The ExpandPath(InputPath) function converts a path from macro format to system format.
Parameters
InputPath
[in] A path in macro format.
Returns
The expanded macro path in system format.
Examples
Path = ExpandPath("%ProgramFilesDir%\Myapp.exe")
Path = C:\Program Files\myapp.exe
All macro paths must escape the % and # characters by replacing these characters with #25 and #23.
Path = ExpandPath("%ProgramFilesDir%\FilenameWithPercent#25.exe")
This expands to C:\Program Files\FileNameWithPercent%.exe.
ExecuteExternalProcess
The ExecuteExternalProcess(CommandLine) function runs a command outside of the virtual environment. You can use this function to make physical system changes.
Parameters
CommandLine
[in] Representation of the application and command-line parameters to run outside of the virtual environment.
Returns
Integer process ID. You can use the process ID with the WaitForProcess function. For more information about “WaitForProcess” see ThinApp Package.ini Paramer Reference Gudie.
Examples
ExecuteExternalProcess("C:\WINDOWS\system32\cmd.exe /c copy C:\systemfile.txt C:\newsystemfile.txt")
You can run a command that requires quotation marks in the command line.
ExecuteExternalProcess("regsvr32 /s " & chr(34) & "C:\Program Files\my.ocx" & chr(34))
ExecuteVirtualProcess
The ExecuteVirtualProcess(CommandLine) function runs a command inside of the virtual environment. You can use this function to make changes to the virtual environment.
Parameters
CommandLine
[in] Representation of the application and command-line parameters to run outside of the virtual environment.
Returns
Integer process ID. You can use the process ID with the WaitForProcess function. For more information about “WaitForProcess” see ThinApp Package.ini Paramer Reference Gudie.
Examples
ExecuteVirtualProcess("C:\WINDOWS\system32\cmd.exe /c copy C:\systemfile.txt C:\virtualfile.txt")
You can run a command that requires quotation marks in the command line.
ExecuteVirtualProcess("regsvr32 /s " & chr(34) & "C:\Program Files\my.ocx" & chr(34))
GetBuildOption
The GetBuildOption(OptionName) function returns the value of a setting specified in the [BuildOptions] section of the Package.ini file used for capturing applications.
Parameters
OptionName
[in] Name of the setting.
Returns
This function returns a string value. If the requested option name does not exist, the function returns an empty string ("").
Examples
Package.ini contains:
[BuildOptions]
CapturedUsingVersion=4.0.1-2866
The following line appears in a VBS file:
Value = GetBuildOption("CapturedUsingVersion")
GetFileVersionValue
The GetFileVersionValue(Filename, Value) function returns version information value from files such as a specific DLL, OCX, or executable file. You can use this function to determine the internal version number of a DLL or retrieve DLL information about the copyright owner or a product name.
Parameters
Filename
[in] The name of the filename whose version information is being retrieved.
Value
[in] The name of the value to retrieve from the version information section of the specified file.
You can retrieve the following values from most DLLs:
Returns
This function returns a string value. If the requested filename does not exist, or the function cannot locate the specified value in the file, the function returns an empty string ("").
Examples
FileVersion = GetFileVersionValue("C:\windows\system32\kernel32.dll," "FileVersion")
 
if FileVersion = "1.0.0.0" then
MsgBox "This is Version 1.0!"
 
End if
GetCommandLine
The GetCommandLine function accesses the command-line parameters passed to the running program.
Returns
This function returns a string that represents the command-line arguments passed to the current running program, including the original executable file.
Examples
MsgBox "The command line for this EXE was " + GetCommandLine
GetCurrentProcessName
The GetCurrentProcessName function accesses the full virtual path name of the current process.
Returns
This function returns a string that represents the full executable path name inside of the virtual environment. In most circumstances, this path is C:\Program Files\..., even if the package source runs from a network share.
Examples
MsgBox "Running EXE path is " + GetCurrentProcessName
GetOSVersion  
The GetOSVersion() function returns information about the current version of Windows.
Parameters
This function has no parameters.
Returns
This function returns a string in the MAJOR.MINOR.BUILD_NUMBER.PLATFORM_ID OS_STRING format.
MAJOR is one the following values:
MINOR is one of the following values:
BUILD_NUMBER is the build number of the operating system.
PLATFORM_ID assigns one of the following values:
Value = 1 for Windows Me, Windows 98, or Windows 95 (Windows 95 based OS)
Value = 2 for Windows Server 2003, Windows XP, Windows 2000, or Windows NT. (Windows NT based OS)
OS_STRING represents information about the operating system such as Service Pack 2.
Examples
if GetOSVersion() = "5.1.0.2 Service Pack 2"
then MsgBox "You are running on Windows XP Service Pack 2!"
endif
GetEnvironmentVariable
The GetEnvironmentVariable(Name) function returns the environment variable associated with the Name variable.
Parameters
Name
[in] The name of the environment variable for which the value is retrieved.
Returns
This function returns the string value associated with the Name environment variable.
Examples
MsgBbox "The package source EXE is " + GetEnvironmentVariable("TS_ORIGIN")
RemoveSandboxOnExit
The RemoveSandboxOnExit(YesNo) function set toggles that determine whether to delete the sandbox when the last child process exits.
If you set the RemoveSandboxOnExit parameter to 1 in the Package.ini file, the default cleanup behavior for the package with is Yes. You can change the cleanup behavior to No by calling RemoveSandboxOnExit with the value of 0. If you do not modify the RemoveSandboxOnExit=1 entry in the Package.ini file, the default cleanup behavior for the package is No. You can change the cleanup behavior to Yes by calling RemoveSandboxOnExit with the value of 1.
Parameters
Yes No
[in] Do you want to clean up when the last process shuts down? 1=Yes, 0=No
Examples
The following example turns on cleanup.
RemoveSandboxOnExit 1
The following example turns off cleanup.
RemoveSandboxOnExit 0
SetEnvironmentVariable
The SetEnvironmentVariable(Name, Value) function set the value of an environment variable.
Parameters
Name
[in] The name of the environment variable to store the value.
Value
[in] The value to store.
Examples
SetEnvironmentVariable "PATH", "C:\Windows\system32"
SetfileSystemIsolation
The Setfile systemIsolation(Directory, IsolationMode) function sets the isolation mode of a directory.
Parameters
Directory
[in] Full path of the directory whose isolation mode is to be set.
IsolationMode
[in] Isolation mode to set.
1 = WriteCopy
2 = Merged
3 = Full
Examples
You can set the Merged isolation mode for the temp directory.
Setfile systemIsolation GetEnvironmentVariable("TEMP"), 2
SetRegistryIsolation
The SetRegistryIsolation(RegistryKey, IsolationMode) function sets the isolation mode of a registry key.
Parameters
RegistryKey
[in] The registry key on which to set the isolation mode. Start with HKLM for HKEY_LOCAL_MACHINE, HKCU for HKEY_CURRENT_USER, and HKCR for HKEY_CLASSES_ROOT.
IsolationMode
[in] Isolation mode to set.
1 = WriteCopy
2 = Merged
3 = Full
Examples
You can set the Full isolation mode for HKEY_CURRENT_USER\Software\Thinapp\Test.
SetRegistryIsolation "HKCU\Software\Thinapp\Test," 3
WaitForProcess
The WaitForProcess(ProcessID, TimeOutInMilliSeconds) function waits until the process ID is finished running.
Parameters
ProcessID
[in] The process ID to end. The process ID can come from ExecuteExternalProcess or ExecuteVirtualProcess.
TimeOutInMilliSeconds
[in] The maximum amount of time to wait for the process to finish running before continuing. A value of 0 specifies INFINITE.
Returns
This function returns an integer.
0 = Timeout fails
1 = Process exits
2 = Process does not exist or security is denied
Examples
id = ExecuteExternalProcess("C:WINDOWS\system32\cmd.exe")
WaitForProcess(id, 0)