Replacing% ~ dp0 in VBScript
3 answers
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName(Wscript.ScriptFullName)
Taken from here:
To use the resulting value in a script, add a reference to the variable where you need its value. For example:
Shell.run GetTheParent & "\test.bat", vbhide
+3
source to share
To get the folder executing .VBS is located in:
type dp0.vbs
Option Explicit
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
WScript.Echo "WScript.ScriptFullName", WScript.ScriptFullName
WScript.Echo "oFS.GetParentFolderName(WScript.ScriptFullName)", oFS.GetParentFolderName(WScript.ScriptFullName
)
cscript dp0.vbs
WScript.ScriptFullName E:\trials\SoTrials\answers\tools\jscript\ijs\dp0.vbs
oFS.GetParentFolderName(WScript.ScriptFullName) E:\trials\SoTrials\answers\tools\jscript\ijs
0
source to share