views:

28

answers:

3

I am trying the windows shell file which will be inserted in the folder where it will analyze folders content.

Now i would like to know how can i detect which is the current path ? i.e. location where the vbs file is placed using FileSystemObject?

Set objFSO = CreateObject("Scripting.FileSystemObject")

+1  A: 

You can get that from WScript.ScriptFullName. Just remove the filename from the end (the bit after the last backslash). I normally use JScript for scripts, but IIRC VBScript has an InStrRev function that will help you find the last backslash. Or: Create a File object for the WScript.ScriptFullName path and then use its ParentFolder property. Something like (untested):

Dim objFSO
Dim objFile
Dim objFolder

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(WScript.ScriptFullName)
Set objFolder = objFile.ParentFolder
T.J. Crowder
+1  A: 

To get the full path only without the extension I use Replace(WScript.ScriptFullName, WScript.ScriptName, "") to just result in a filepath

Bobby
+2  A: 
Set objFS = CreateObject("Scripting.FileSystemObject")
WScript.Echo objFS.GetParentFolderName(WScript.ScriptFullName)
ghostdog74