I'm currently developing a number of VBScript scripts for use with the BlueZone terminal emulator. Many of these files need access to external data files that are stored in the same location as the scripts themselves. On my own computer, I've hard-coded the full path name into the script and they work fine, but I'm now trying to re-distribute these scripts around the office through a private Git repository and have run into a problem.
Obviously, with the files being stored on different computers, including shared drives, the hard-coded directory name does not work anymore, so I need a way to read the name of the directory that the script is stored in. All the advice I have been able to find has said that the command WScript.ScriptFullName will give me that. Unfortunately, as these scripts are being run through BlueZone, I don't actually have access to that object, but the situation is a little confusing.
For example, the following code line seem to work as expected:
Dim myObject : Set myObject = CreateObject("WScript.Network")
So does this:
Dim myObject : Set myObject = CreateObject("WScript.Shell")
But this one doesn't:
MsgBox WScript.Name
Instead I get the follwoing error message:
I get a slightly different error message with the following line:
Dim myObject : Set myObject = CreateObject("WScript")
So it seems that I have access to the sub-objects of WScript, but not the object itself, which doesn't make much sense. The BlueZone environment seems to use its own automation object as a replacement for the WScript object, but there's nothing in the documentation about getting access to the script directory configured under BlueZone itself.
Another attempt was the following code:
Dim myObject : Set myObject = CreateObject("Scripting.FileSystemObject")
Dim WD : WD = myObject.GetAbsolutePathName (".")
But this only gives the directory of BlueZone itself, not the scripts directory. Other than hard-coding each individual copy of each individual script (which means not being able to use a central repository), I don't see any other way around this problem.
Any ideas?