출처: http://communities.vmware.com/message/933916;jsessionid=7E6B917795659832BE8AC13982EC5503


Thanks to Travis (VMWare) engineer, I can clarify this question.

Thinstall creates various Environment Variables. Now, for those of you who are heavy programmers, the term "environment variables" may suggest something that is specific to the application or programming environment, not the environment of the actual computer. Thus, you may overlook the true power of these variables. Environment Variables are those variables registered in the system and can be viewed in XP by going to My Computer, right mouse click, choose Properties, go to Advanced tab and press the button at the bottom called Environment Variables.

When a thinstalled application runs, it automatically creates an environment variable called "TS_ORIGIN".

To retrieve this variable setting in VB.NET you should use the following code:

Dim myText, InstallLocation As String

Dim LastSlash As Integer

Dim SourcePath As String = Environment.GetEnvironmentVariable("TS_Origin") 'retrieves the folder path and executable name

LastSlash = InStrRev(SourcePath, "\") 'gets the location of the last slash

InstallLocation = VisualBasic.Left(SourcePath, LastSlash) 'retrieves the folder path (if you just wanted the exe name, then change it to from Left to Right)

For those out there that want to capture other settings that Thinstall does not expose, then write a VbScript (vbs) and save it to the root of the thinstalled prep folder. Thinstall will automatically run all vbs when the application is started. The following is an example of a vbscript to set a "user" environment variable.

Dim objWSH
Dim objUserVariables
Dim Origin
Dim LastSlash
Dim SourcePath

'retrieve the current location
Origin = GetEnvironmentVariable("TS_ORIGIN")

'clean up the source location
LastSlash = InStrRev(Origin, "\")
SourcePath = Left(Origin, LastSlash)

'retrieve the user variables
Set objWSH = CreateObject("WScript.Shell")
Set objUserVariables = objWSH.Environment("USER")

'set the local variable to be retrieved by the .NET application
objUserVariables("Application.StartupPath") = SourcePath
msgbox SourcePath

Hope this helps somebody else in the future!

-Eric

AND