Page 1 of 1 1
Topic Options
#113318 - 2004-02-04 06:40 PM UDF to convert mapped drives to UNC path?
pearly Offline
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
#113319 - 2004-02-04 06:43 PM Re: UDF to convert mapped drives to UNC path?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
You can read this via registry at HKCU\Network or via WMI.
_________________________
There are two types of vessels, submarines and targets.

Top
#113320 - 2004-02-04 06:48 PM Re: UDF to convert mapped drives to UNC path?
pearly Offline
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. Offline
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 Offline
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
#113323 - 2004-02-04 08:01 PM Re: UDF to convert mapped drives to UNC path?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Reading the reg has to be the most reliable as WMI and WSH have overhead and dependencies.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#113324 - 2004-02-04 08:05 PM Re: UDF to convert mapped drives to UNC path?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
However, the registry will not contain information about non-persistently mapped drives.
_________________________
There are two types of vessels, submarines and targets.

Top
#113325 - 2004-02-04 08:09 PM Re: UDF to convert mapped drives to UNC path?
pearly Offline
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
#113326 - 2004-02-04 08:15 PM Re: UDF to convert mapped drives to UNC path?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Yes.
_________________________
There are two types of vessels, submarines and targets.

Top
#113327 - 2004-02-05 12:55 AM Re: UDF to convert mapped drives to UNC path?
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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?

Top
#113328 - 2004-02-05 01:18 AM Re: UDF to convert mapped drives to UNC path?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
see driveenum() and driveprop() UDFs
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#113329 - 2004-02-05 07:50 PM Re: UDF to convert mapped drives to UNC path?
pearly Offline
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
#113330 - 2004-02-05 08:31 PM Re: UDF to convert mapped drives to UNC path?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, if the reg does not have info on them, how do you then do label in mapdrive?
_________________________
!

download KiXnet

Top
#113331 - 2004-02-05 08:35 PM Re: UDF to convert mapped drives to UNC path?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, found the info.
it's at:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints

so, info about non-persistent mapped drives IS in registry.
_________________________
!

download KiXnet

Top
#113332 - 2004-02-05 09:23 PM Re: UDF to convert mapped drives to UNC path?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Yeah, I was just thinking about HKCU\Network, should know the other location by now ;-)
_________________________
There are two types of vessels, submarines and targets.

Top
#113333 - 2004-02-05 10:08 PM Re: UDF to convert mapped drives to UNC path?
Chris S. Offline
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
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.066 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org