I understand the question but don't have an answer yet. How are you invoking the script? I ask because it might be possible to pass the script location as a argument to the script...?
Unfortunately, the answer is both yes and no, depending upon the application. In xPCB Automation documentation, the source folder for a running script can be determined from ScriptHelper.Arguments(2). But, xDX Automation does not have access to ScriptHelper.
I filed this issue as a service request in May 2017 (SR #2962701072: How can a running script find its source folder?), which was quickly closed with the standard statement to submit this item as an enhancement request on the Ideas site. (IOW: Go pound sand).
Did you file an Idea? If so, please post the link here so that more people can vote for it.
If mgcscript is used to invoke the script then ScriptHelper.Arguments CAN be used to obtain script's complete full name for DxDesigner as well. Here's an example:
Set ScriptArgs = ScriptHelper.Arguments
Dim arg1, sScriptName
arg1 = ScriptArgs.Item(1)
sScriptName = ScriptArgs.item(2)
MsgBox "arg1 is " & arg1
MsgBox "Script name is " & sScriptName
Thanks for answers. I don't like the option to pass a parameter for that (I don't need just the one or another value).
I will load some shared script or own include-files and to make a kind of things editable for me and admins. sometimes also just a .cfg in format of VBScript (Const etc.) So I load some own include scripts, like Classes/Basefuncs etc...
Set hwnd = fso.OpenTextFile("<path of scriptform>\include.vbs",1,False)
ExecuteGlobal hwnd.ReadAll() ' -- Include Class script
Set hwnd = Nothing
The big advantage is, that I can store some controlled code out of a .efm formular. Unique Basefunctions maybe, that use different .efm's or anything else. When I read right, there is no way to currently find out the scripts-path? it's a pity
Okay my solution now is... to store my include-scripts in a fixed path and create a Systemvariable (Environment) for that path...
Set WshShell = CreateObject("Wscript.Shell")
AATK, XPKGUTILS, vendor specific toolkits, and my customers all set an environment variable to specify the root of their scripting directory. That way one script can call another, get icons...