Link to home
Start Free TrialLog in
Avatar of uncle_ho
uncle_hoFlag for United States of America

asked on

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?

Thanks.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

You could try the WScript.CurrentDirectory() property:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/a36f684c-efef-4069-9102-21b3d1d55e9e.asp

    Dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WScript.Echo WshShell.CurrentDirectory
That is, change the current directory to your virtual one, then call CurrentDirectory() and see what comes back...
Avatar of uncle_ho

ASKER

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.
Explain what you mean by a "virtual path" please...
Sorry if I wasn't being clear.  I need to return a physical path from a UNC path to a virtual directory.

E.g.:
\\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?
ASKER CERTIFIED SOLUTION
Avatar of sr75
sr75
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.