Return physical path in VBScript

I have run into a memory error in a few different circumstances making a FileSystemObject GetParentFolderName call.  I think it may be running into problems because I am passing the function a virtual path and not a physical path.  Is there a way in VBScript to find the physical path from a virtual one?  This is a stand-alone vbs script file (not in an ASP page) so I cannot use Server.MapPath().  Any equivalents that will work in a similar manner?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
You could try the WScript.CurrentDirectory() property:

    Dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WScript.Echo WshShell.CurrentDirectory
Mike TomlinsonMiddle School Assistant TeacherCommented:
That is, change the current directory to your virtual one, then call CurrentDirectory() and see what comes back...
uncle_hoAuthor Commented:
How can the current directory be changed to the virtual one?  The script will be running in a different directory than the one I am referencing via the virtual path.  Won't the CurrentDirectory call always return the path of the directory in which the script is running?

Thanks for your ideas.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Explain what you mean by a "virtual path" please...
uncle_hoAuthor Commented:
Sorry if I wasn't being clear.  I need to return a physical path from a UNC path to a virtual directory.

\\server_name\virtual_dir\some_client_folder\   --->   H:\data\some_client_folder\
Let me see if I understand you correctly?

You want to get the actual path for a share on the machine that is sharing it out?
If that is the case you can use the WMI W32_Share method.

Here is an example for getting the path of the share.  I am sure you can modify it for your needs.


Option Explicit

Dim objWMI
Dim colClass
Dim objClass

Dim strComputer

strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colClass = objWMI.ExecQuery("Select * from Win32_Share",,48)

WScript.Echo "Query: Win32_Share::Path"
On Error Resume Next

For Each objClass in colClass
WScript.Echo "Path: " & objClass.Path

Set objWMI = Nothing
Set colClass = Nothing
Set objClass = Nothing

<end script>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
uncle_hoAuthor Commented:
I think this will work for me.  I have added a where clause to the query to specify the share name I need the physical path for.

Thanks for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.