#76231 - 2003-07-31 08:05 PM
Label network drive
|
Luis Arnauth
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
|
|
|
|
#76233 - 2003-07-31 08:21 PM
Re: Label network drive
|
Luis Arnauth
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
|
|
|
|
#76236 - 2003-07-31 08:39 PM
Re: Label network drive
|
Luis Arnauth
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
|
|
|
|
#76238 - 2003-08-18 11:03 AM
Re: Label network drive
|
Luis Arnauth
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
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 365 anonymous users online.
|
|
|