?
Solved

Return physical path in VBScript

Posted on 2006-04-04
8
Medium Priority
?
1,747 Views
Last Modified: 2011-10-03
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.
0
Comment
Question by:uncle_ho
  • 3
  • 3
  • 2
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16374482
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
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16374493
That is, change the current directory to your virtual one, then call CurrentDirectory() and see what comes back...
0
 
LVL 1

Author Comment

by:uncle_ho
ID: 16374691
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16375215
Explain what you mean by a "virtual path" please...
0
 
LVL 1

Author Comment

by:uncle_ho
ID: 16376117
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\
0
 
LVL 15

Expert Comment

by:sr75
ID: 16376351
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?
0
 
LVL 15

Accepted Solution

by:
sr75 earned 2000 total points
ID: 16376391
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.

<script>

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
Next

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

<end script>
0
 
LVL 1

Author Comment

by:uncle_ho
ID: 16381362
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question