1

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?

2 Answers 2

1

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 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but this isn't running in ASP. It's running locally on users' machines. I just need to ensure that the file is not being run from anywhere other than it is supposed to, as we're having issues with users moving the file
Thank again, but afraid the WScript.Network only returns Computer Name, and the same for the examples on the link. The problem is that different offices have different drives mapped to the same letter, so just checking that a file resides on S:\ is not sufficient. I guess the answer is somehow to resolve the full server path from a drive letter
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.