Page 1 of 1 1
Topic Options
#76231 - 2003-07-31 08:05 PM Label network drive
Luis Arnauth Offline
Fresh Scripter

Registered: 2003-03-06
Posts: 13
Hello all,

I'm using MapDrive UDF from Jens Meyer (sealeopard@usa.net) to map network drives, but it seems that clients with win2k have problems with the 'labeling' facilitie...

Is there a limitation to the label (less then 20)?

The UDF is below, thank you all.
code:
;FUNCTION      MapDrive
;ACTION Maps a UNC name to a specific driveletter
;AUTHOR Jens Meyer (sealeopard@usa.net)
;VERSION 1.44 (removed issue where label was not applied when mapping to already mapped drive)
; 1.43
;DATE CREATED 2001/12/20
;DATE MODIFIED 2003/05/13
;KIXTART 4.12+
;SYNTAX MAPDRIVE(DRIVE, UNC [, PERSISTENCE, LABEL])
;PARAMETERS DRIVE
; Required string containing driveletter or *
; UNC
; Required string containing UNC name
; PERSISTENCE
; Optional boolean indicating a persistent connection
; LABEL
; Optional string to relabel a mapped share (Windows 2000/XP/2003 only)
;RETURNS 0 or the error code @error
;REMARKS 'Persistent' is not supported under Windows 9x to prevent different users
; from receiving drive shares they should not have access to. Deep mapping is
; not supported under Windows 9x.
;DEPENDENCIES none
;EXAMPLE $rc = MAPDRIVE('z','\\SERVER\share',1)
; $rc = MAPDRIVE('*','\\SERVER\share',0,'whatever')
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000108
Function mapdrive($drive, $unc, optional $persist, optional $label)
Dim $mount, $subkey, $regvalue, $rc, $iErr, $driveobj
Dim $deep, $regkey
Select
Case @INWIN=2
$persist=0
Case NOT VarType($persist)
$persist=0
Case $persist
$persist=1
Case 1
$persist=0
EndSelect
$drive=Ucase(Trim($drive))
If ($drive<'C' OR $drive>'Z') AND $drive<>'*'
$mapdrive=15
Exit 15
EndIf
$mount=$drive+':'
$mapdrive=0
If Right($unc,1)='\'
$unc=Left($unc,Len($unc)-1)
EndIf
$deep=Split($unc,'\')
If Ubound($deep)>3
$deep=1
Else
$deep=0
EndIf
If @INWIN=1
$subkey='HKEY_USERS\'+@SID+'\Network\'+$drive
Else
$subkey='HKEY_CURRENT_USER\Network\'+$drive
EndIf
If KeyExist($subkey)
$regvalue=Lcase(ReadValue($subkey,'RemotePath'))
If $regvalue<>Lcase(Trim($unc)) OR $persist=0
Use $mount /delete /persistent
If KeyExist($subkey)
$rc=DelKey($subkey)
EndIf
EndIf
EndIf
If NOT Exist($mount)
Select
Case ($deep OR InStr($unc,'\\'+@WKSTA+'\')) AND @INWIN=2
$iErr=3
Case $deep AND Val(@DOS)=4
Shell 'subst '+$mount+' '+$unc
$iErr=@ERROR
Case $persist
Use $mount $unc /persistent
$iErr=@ERROR
Case 1
Use $mount $unc
$iErr=@ERROR
EndSelect
EndIf
If $label AND Val(@DOS)>4 AND NOT $iErr
$driveobj=CreateObject('shell.application')
$iErr=@ERROR
If NOT $iErr
$driveobj.namespace($mount+'\').self.name=$label
$iErr=@error
EndIf
$driveobj=''
EndIf
Debug off
$mapdrive=$iErr
Exit $iErr
EndFunction

MapDrive('l','\\$MyFileServer\ESEGUR-LIS-DGTV-TRTMNTCLNTS',0,'LIS-DGTV-TRTMNTCLNTS')

Luis Arnauth

Top
#76232 - 2003-07-31 08:09 PM Re: Label network drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
That name works for me without any problems.
_________________________
There are two types of vessels, submarines and targets.

Top
#76233 - 2003-07-31 08:21 PM Re: Label network drive
Luis Arnauth Offline
Fresh Scripter

Registered: 2003-03-06
Posts: 13
For me to...

With XP PRO, but with 2000 it seems stuck to the conventionl label...

Before i used your UDF i've tried another one that didn't work as well.

And if i unmaped the drive first it still doesn't work. I've used the following for unmapping:

code:
 Use "*" /DELETE 

Perhaps it's a registry setting ?

Thanks

Luis Arnauth

Top
#76234 - 2003-07-31 08:32 PM Re: Label network drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Try running it under different users, e.g. Administrator/Power User/User/Restricted User.
_________________________
There are two types of vessels, submarines and targets.

Top
#76235 - 2003-07-31 08:32 PM Re: Label network drive
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Put Debug on just before the line:
If $label AND Val(@DOS)>4 AND NOT $iErr
and single step through the label portion.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#76236 - 2003-07-31 08:39 PM Re: Label network drive
Luis Arnauth Offline
Fresh Scripter

Registered: 2003-03-06
Posts: 13
I've tried with all kind of users.

I've also discovered that if i edited the label my self (as a standart user) and label it as 'xpto' then run the script it labels the drive perfectly...

By the way how do i put the DEBUG ?

Luis Arnauth

Top
#76237 - 2003-07-31 08:56 PM Re: Label network drive
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I thought I explained how... [Frown]
code:
Debug on
If $label AND Val(@DOS)>4 AND NOT $iErr
$driveobj=CreateObject('shell.application')
$iErr=@ERROR
If NOT $iErr
$driveobj.namespace($mount+'\').self.name=$label
$iErr=@error
EndIf
$driveobj=''
EndIf
Debug off


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#76238 - 2003-08-18 11:03 AM Re: Label network drive
Luis Arnauth Offline
Fresh Scripter

Registered: 2003-03-06
Posts: 13
I´ve putted the DEBUG ON some time ago and went to verify on Win2k machines the if statement completed always, but odd enough sometimes it put a label on the drive and other don't...

Could it be my:
code:
  USE "*" /DELETE

?
Thank you
Luis Arnauth

Top
#76239 - 2003-08-18 11:32 AM Re: Label network drive
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no.
the labeling function is from out there and it's author has been checking on this for some days.

there is no real reason why it does that as it shouldn't.
the only reason that one can think is that windows2000 has asynchronous mapping but MS has not documented it as they don't want to ppl know too much.

basically, the problem with naming is perfectly normal with w2k.
and it can't be fixed.
and it's not about map-udf but about label-udf.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 365 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.19 seconds in which 0.091 seconds were spent on a total of 13 queries. Zlib compression enabled.

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