#113318 - 2004-02-04 06:40 PM
UDF to convert mapped drives to UNC path?
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
Is there a UDF to convert mapped drives to UNC path? I have tried searching, but to no avail.
Thanks!~
|
Top
|
|
|
|
#113320 - 2004-02-04 06:48 PM
Re: UDF to convert mapped drives to UNC path?
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
Ahh, thanks Jens! I didn't know that before.
|
Top
|
|
|
|
#113321 - 2004-02-04 07:07 PM
Re: UDF to convert mapped drives to UNC path?
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
There's also WSH...
Code:
Break On
$rc=setoption('explicit','on') $rc=setoption('novarsinstrings','on') $rc=setoption('wrapateol','on')
Dim $WshNetwork,$oDrives,$i
$WshNetwork = CreateObject("WScript.Network") $oDrives = $WshNetwork.EnumNetworkDrives
"Network drive mappings:" ? For $i = 0 to $oDrives.Count - 1 Step 2 "Drive " + $oDrives.Item($i) + " = " + $oDrives.Item($i+1) ? Next
|
Top
|
|
|
|
#113322 - 2004-02-04 07:43 PM
Re: UDF to convert mapped drives to UNC path?
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
Thanks Chris! Is there a preferred/reliable method or are they basically all the same?
|
Top
|
|
|
|
#113325 - 2004-02-04 08:09 PM
Re: UDF to convert mapped drives to UNC path?
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
Thanks for your quick response, Les and Jens.
Quote:
However, the registry will not contain information about non-persistently mapped drives.
But WMI and/or WSH does?
|
Top
|
|
|
|
#113328 - 2004-02-05 01:18 AM
Re: UDF to convert mapped drives to UNC path?
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
see driveenum() and driveprop() UDFs
|
Top
|
|
|
|
#113329 - 2004-02-05 07:50 PM
Re: UDF to convert mapped drives to UNC path?
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
Quote:
There's also a way to retrieve the information using FSO (File System Object), which would be more available (from an operating system standpoint).
Do you have some specific requirements? Do you want to return a collection of all mapped network drives and their UNC path? Do you just want to query a single drive letter?
Basically when the user browses for a file/folder using GUIDialog (by Lonkero), if it's a mapped drive path, I want to convert to UNC path. I've already implemented the use of the reg. Do you think this is sufficient?
|
Top
|
|
|
|
#113333 - 2004-02-05 10:08 PM
Re: UDF to convert mapped drives to UNC path?
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Give this a try...
Code:
Break On
$nul = SetOption('Explicit','On') $nul = SetOption('NoVarsInStrings','On') $nul = SetOption('WrapAtEOL','On')
Dim $sUNC
$sUNC = fnGetUNC('E:\') $sUNC ? @ERROR " | " @SERROR ?
Function fnGetUNC($sDrive) Dim $oFSO,$oDrive $oFSO = CreateObject('Scripting.FileSystemObject') If @ERROR Exit @ERROR EndIf If $oFSO.DriveExists($sDrive) $oDrive = $oFSO.GetDrive($sDrive) If $oDrive.DriveType = 3 $fnGetUNC = $oDrive.ShareName Else Exit 1 EndIf Else Exit 15 EndIf EndFunction
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|