0
votes

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:

BlueZone 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?

2

2 Answers

1
votes

SOLVED!

After some digging, BlueZone Support finally found an undocumented ScriptFolder() method in the BlueZone Host Automation object.

So the code:

Set bzhao = CreateObject("BZWhll.WhllObj")
bzhao.Connect ""
MsgBox bzhao.ScriptFolder

is functionally similar to the line:

MsgBox WScript.ScriptFullName

I'm not sure that the two methods are exactly equivalent, but it's adequate enough for my purposes.

0
votes

Your script host doesn't provide a WScript object (which is unrelated to the WScript.Shell COM object). cscript.exe and wscript.exe provide that object, other script hosts, like mshta.exe (and apparently BlueZone) don't.

Unless Rocket provides you with an alternative method to obtain the script path the only workaround I see is to start each script with the working directory set to the directory containing the script. That way you can get the script path like this:

Set fso = CreateObject("Scripting.FileSystemObject")
cwd = fso.GetAbsolutePathName(".")

or like this:

Set sh = CreateObject("WScript.Shell")
cwd = sh.CurrentDirectory