Retrieve computer share name from a drive letter?
Retrieve computer share name from a drive letter?
(OP)
say I have "h:\" mapped to "\\computername\bobsdrive"
What is the proper code to go about retrieving the name?
I want to retrieve "\\computername\bobsdrive"
Do I have to go about using API?
Could someone help me out with this one?
What is the proper code to go about retrieving the name?
I want to retrieve "\\computername\bobsdrive"
Do I have to go about using API?
Could someone help me out with this one?
RE: Retrieve computer share name from a drive letter?
Something like this:
FUNCTION GetUNCPath
LPARAMETERS tcMappedDriveLetter
LOCAL lcRetPath,WshNetwork,oDrives,i
lcRetPath = '
IF TYPE('tcMappedDriveLetter')<>'C'
RETURN lcRetPath
ENDIF
tcMappedDriveLetter=LEFT(tcMappedDriveLetter,1)
IF !DIRECTORY(tcMappedDriveLetter+':')
RETURN lcRetPath
ENDIF
WshNetwork = CREATEOBJECT("WScript.Network")
oDrives = WshNetwork.EnumNetworkDrives
*NOTE: this array is 0 based
FOR i = 0 To oDrives.Count - 1
IF oDrives.Item(i)=tcMappedDriveLetter
lcRetPath=oDrives.Item(i+1)
EXIT
ENDIF
ENDFOR
RETURN lcRetPath
ENDFUNC
If you can't use the WSH for whatever reasons, you can still do it with the API. I just prefer the WSH. :-)
Jon Hawkins
jonscott8@yahoo.com
Carpe Diem! - Seize the Day!
RE: Retrieve computer share name from a drive letter?
I'll let you know.
:)
RE: Retrieve computer share name from a drive letter?
RE: Retrieve computer share name from a drive letter?
LOL. Thanks. I'd been down the mapped drive path before, so it was fairly easy for me to recollect.
Thank you very much
You're welcome. Glad I could help.
Jon Hawkins
jonscott8@yahoo.com
Carpe Diem! - Seize the Day!