Question

is it possible to get the full server path of a VBScript file while it is running, but instead of showing the drive letter, it shows the server name?

I know I can use FileSystemObject's GetAbsolutePath, but instead of it showing S:\Some Folder\FileName.vbs, it shows \\servername\Some Folder\FileName.vbs?

Was it helpful?

Solution 2

Found the solution, I can retrieve the drive letter using FileSystemObject.GetAbsolutePathName(""), and then use this code to convert the drive letter to the full UNC path, which works well: http://support.microsoft.com/kb/160529

OTHER TIPS

VBScript runs in client side and you are trying to get the server path

May be you can try some thing like below

<script language="vbscript">
    dim path
    path = "<%=Request.PhysicalApplicationPath %>"
    alert(path)
</script>

If you trying to use vbScript in an ASP/ASP.NET page, then you try using Server.MapPath as well.

<%=Server.MapPath("your file name")%>

edit ---

Seems like in your case you are interested in finding the mapped drives of the user that is logged in. You could something like:

Set objNetwork = WScript.CreateObject("WScript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
   Wscript.Echo colDrives.Item(i) & vbTab & colDrives.Item (i + 1)
Next
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top