Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Retrieve Full FilePath from saved file using Mapped Drives

Posted on 2007-11-19
2
Medium Priority
?
773 Views
Last Modified: 2013-12-18
I have lotusscript that is detaching OLE objects to end user selected file location.  If the user uses a mapped drive I want my script to determine the actual file location on the server.  
ie.
if "Z:\filename.xxx is returned, I need to know server and filepath.
ie.
\\server\filpath\filename.xxx
0
Comment
Question by:Robert Treadwell
2 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 20317077
You will need to capture the list of all the mapped drives possibly by using the net command  to show and output to a text file that you can read, or with WIn32 API , and then substitute as needed.

net use > list01.txt

should show the connected, mapped drives.
You will need to parse it and then substitute as needed.


I hope this helps !

0
 
LVL 31

Accepted Solution

by:
qwaletee earned 1000 total points
ID: 20322980

Function ConvertToUNC(Byval letterPath As String) As String
	If Left$(letterPath,2) = "\\" Then 'already a full UNC
		ConvertToUNC = letterPath
		Exit Function
	Elseif Left$(letterPath,1) = "\" Then 'path off current drive
		letterPath = Curdrive$ & letterPath
	REM two possibilities left, either it is a DOS path (x:\folder) or just a folder (NOTES\DATA) that needs current directory in front
	Elseif Mid$(letterPath,2,1) <> ":" Then
		letterPath = Curdir$ & "\" & letterPath
	End If
	
	Dim drive As String, tree As String, network As Variant, drives As Variant, index As Integer, limit As Integer
	drive = Ucase(Left$(letterPath,2))
	tree = Mid$(letterPath,3)
	Set network = CreateObject("WScript.Network")
	Set drives = network.EnumNetworkDrives()
	limit = drives.Count()-1 '0 index, so count is one above the Ubound
	For index = 0 To limit Step 2
		If Ucase(drives(index)) = drive Then
			ConvertToUNC = drives(index+1) & tree
			Exit Function
		End If
	Next index
	ConvertToUnc = drive & tree
End Function

Open in new window

0

Featured Post

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.

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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