Get Current Directory (VBscript)

The below script shows two methods to find the current directory.

‘===Get Current Directory
‘Method 1:
set wshell = createobject(“”)
wscript.echo wshell.currentdirectory

‘Method 2:

Set wshell= CreateObject(“WScript.Shell”)
Set objfso = CreateObject(“Scripting.FileSystemObject”)

wshell.CurrentDirectory = objfso.GetParentFolderName(Wscript.ScriptFullName)

wscript.echo wshell.CurrentDirectory


1 Response to “Get Current Directory (VBscript)”

  1. 1 Kevin Fegan June 23, 2012 at 1:11 pm

    Great article !! Here is another method for your list.

    You could also use: GetAbsolutePathName
    which returns a “String” containing the current directory.

    Dim gstrCurPath
    gstrCurPath = CreateObject(“Scripting.FileSystemObject”).GetAbsolutePathName(“.”)

    WScript.Echo “CurPath=” & gstrCurPath
    WScript.Echo “VarType(CurPath)=” & VarType(gstrCurPath)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: