ScriptIt
(Fresh Scripter)
2005-03-21 10:48 PM
Map drives dynamically

Is there a way to map drives dynamically using the IF INGROUP. In other words, can I use the if ingroup without designating a drive letter?

Kdyer
(KiX Supporter)
2005-03-21 11:51 PM
Re: Map drives dynamically

You can use one of the MAPDRIVE() UDFs to do this..

MapDrive() - Maps a UNC name to a specific driveletter

HTH,

Kent


AllenAdministrator
(KiX Supporter)
2005-03-22 12:05 AM
Re: Map drives dynamically

I believe starting with version 4.22, USE supports *. So your code would look something like this:

Code:
  

use * "\\server\share"
? @result
? @serror



Kdyer
(KiX Supporter)
2005-03-22 12:07 AM
Re: Map drives dynamically

Here is a bit of code that I robbed from my 2433A Course and converted over that should cover this:
Code:

CLS
BREAK ON
$oFSO=CreateObject('Scripting.FileSystemObject')
; Loop through all used drives
;For each $oDrive in $Onetwork.EnumNetworkDrives
For each $drive in $oFSO.Drives
$sFinalDrive=Left($drive,1)
Next
; Convert final used Drive to ASC and add 1 and return to character
$sNextDrive=CHR(ASC($sFinalDrive)+1)+':'
;Map New Drive
USE $sNextDrive '\\<SOMESERVER>\APPS'
IF @ERROR<>0
?'COULD NOT MAP DRIVE DUE TO '+@SERROR
ENDIF



HTH,

Kent


Kdyer
(KiX Supporter)
2005-03-22 12:09 AM
Re: Map drives dynamically

Allen,

You are correct (from page 4 of the guide):
Quote:


USE USE now supports automatic drive selection ("USE * \\server\share").





However, it maps the next available drive as drive Z:, where when I used WSCRIPT version from the 2433A Course, it put my next drive as drive U:.. Hmmmm.

Thanks,

Kent


AllenAdministrator
(KiX Supporter)
2005-03-22 12:13 AM
Re: Map drives dynamically

Yeah... it kinda makes your code above and my MapDriveX() UDF kind of useless.

LonkeroAdministrator
(KiX Master Guru)
2005-03-22 12:29 AM
Re: Map drives dynamically

Quote:

I believe starting with version 4.22, USE supports *. So your code would look something like this:

Code:
  
use * "\\server\share"
? @result
? @serror






I'm not sure do I read correctly.
for far as I know, "use *" has been there since 1990's


LonkeroAdministrator
(KiX Master Guru)
2005-03-22 12:32 AM
Re: Map drives dynamically

weird...
what the heck is that automatic redirection ruud talks about?


AllenAdministrator
(KiX Supporter)
2005-03-22 12:34 AM
Re: Map drives dynamically

* may not have been new, but using it to map drives evidently was... see the pages 3-5, "What's New", of the manual.

LonkeroAdministrator
(KiX Master Guru)
2005-03-22 12:36 AM
Re: Map drives dynamically

trust me, it was there already in 3.47 which dates back to 1998!
and trust me, I know my kixtart and it's "use"


Les
(KiX Master)
2005-03-22 12:40 AM
Re: Map drives dynamically

New or old... it's still a really bad idea.

ScriptWhat
(Lurker)
2005-03-24 03:16 AM
Re: Map drives dynamically

Why is it a bad idea.

Les
(KiX Master)
2005-03-24 03:23 AM
Re: Map drives dynamically

It not only causes confusion for users when the drive letter varies for different individuals but it also results in broken hard links in files.

Kdyer
(KiX Supporter)
2005-03-24 03:35 AM
Re: Map drives dynamically

I have to agree with Les on this one. Drives should be consistent among group members.

Kent


LonkeroAdministrator
(KiX Master Guru)
2005-03-24 06:51 AM
Re: Map drives dynamically

well.
it would force your clients to learn and soon it would be just fine.
hardlinking is a pain anyways.

but, ideal dream is not what I get.
I do also have properly named drives for different groups.


Les
(KiX Master)
2005-03-24 03:01 PM
Re: Map drives dynamically

I abstract the true path by consolidating my shares using DFS. I use just three drive letters that are the same for everybody except of course their home drive which is the same letter but different path but still hosted through the DFS.