VBScript – Get the Current Script Directory in VBScript

0
27

VBScript is fairly straightforward the full path of the running script is available in WScript.ScriptFullName and then you can use the FileSystemObject class to get the parent folder name. Here is the script:

' Determine script location for VBScript
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim sScriptDir : sScriptDir = oFSO.GetParentFolderName(WScript.ScriptFullName)
 
Wscript.Echo "Current script directory is " & sScriptDir