04-22-2016 07:56 AM
Hello,
I am looking to get the name of the current script that is running in DIadem.
So I woudl like to call a script, and then while it is running I would like to record the name of the script (file name on disk) to a text box on a report I am generating.
I know how to pass values to the report I am not sure to get the name of the current script that is executing.
Thanks
Solved! Go to Solution.
04-22-2016 08:23 AM
Hi Tim
You can use the variables CurrentScriptName and CurrentScriptPath.
Hope this helps.
Winfried
04-22-2016 08:32 AM
Awesome Thanks
04-22-2016 09:12 AM
Be aware that the currentScript... command only return the correct path in global script context.
If you use it in scripts that you include you have to store them in gloabl variables to access them.
Lets assume a script foo2.vbs in a subfolder lib
Option Explicit 'Forces the explicit declaration of all the variables in a script. dim foo2path : foo2path = CurrentScriptPath dim foo2Script : foo2Script = CurrentScriptName function Foo2Pathinfo() dim rv : rv = "" rv = rv & "foo2 path: " & foo2path & VBCRLF rv = rv & "foo2 script: " & foo2Script & VBCRLF rv = rv & "foo2 curr path: " & CurrentScriptPath & VBCRLF rv = rv & "foo2 curr script: " & CurrentScriptName & VBCRLF Foo2Pathinfo = rv end function
And a script using it
Option Explicit scriptinclude currentscriptpath & "lib\foo2.vbs" MsgBox "foo1 curr path: " & CurrentScriptPath & VBCRLF &_ "foo1 curr script: " & CurrentScriptName & VBCRLF &_ Foo2Pathinfo()
This will output
foo1 curr path: C:\temp\ foo1 curr script: foo1.vbs foo2 path: C:\temp\lib\ foo2 script: foo2.vbs foo2 curr path: C:\temp\ foo2 curr script: foo1.vbs
Where the last lines are potentially not what you expect.