Page 1 of 1 1
Topic Options
#120421 - 2004-06-01 11:10 AM mapping drives to different letters
Adams Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 6
Hi,

We have a company drive letter that we need to map departmental drives to so we have a simple:
Code:
  
IF InGroup("HR_for_example")
Use Q: '\\server\HR_drive'
ENDIF



which works fine, but the problem is some people seem to belong to 2 different departments and therefore need 2 drive letters, so I was wondering if there was a way to cater for this in a kix script? pseudo code of what I mean:

If in group whatever & drive letter already taken then
map drive to other letter.

the users are not in anymore than 2 departmental groups (for the moment at least,) and there's no pattern of which 2 departments they belong to. I'm not new to programming but I am new to kix scripts so I'd appreciate some help please, can it be done? and if so how?

thanks for any help you can provide.

Top
#120422 - 2004-06-01 12:30 PM Re: mapping drives to different letters
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You can do what you want, but it is a very bad idea.

Much better is to document what drives are going to be needed across your organisation, assign a drive letter to each and ensure that the drive mappings are consistant.

Now your script becomes simply:
Code:

If in group X
Map G: \share
EndIf

If in group Y
Map T: \othershare
EndIf

...and so on ...



It would be highly unusual to need have the same share mapped to different drive letters.

Top
#120423 - 2004-06-01 01:03 PM Re: mapping drives to different letters
Adams Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 6
agreed that this would be far easier to do, but [storymode] we have been bought by a much larger global company, and we have to adopt their standards, which is having a single letter 'Q' as the department drive. I think one of the arguments behind it is that troubleshooting can be done by anyone anywhere in the world cos everyone's using the same standard and can talk someone through it. but that's going a bit off-topic. [/storymode]

what it boils down to is we need to have Q as the department drive, and technically we shouldn't even be adding this other drive letter in as it's not standard practice, but these people need access to it, so we're gonna have to do it like that (unless anyone knows a different way to get around the problem.)

So you say it can be done, that's good news, can you show me how please?

Top
#120424 - 2004-06-01 01:32 PM Re: mapping drives to different letters
Gos Offline
Fresh Scripter

Registered: 2004-05-28
Posts: 23
Another way could be like this:

If in group X
Map G: \share
EndIf

If in group Y
Map G: \othershare
EndIf

If in group X AND in group Y
Map G: \share
Map J: \othershare
EndIf

-Gos-

Top
#120425 - 2004-06-01 01:37 PM Re: mapping drives to different letters
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
So why not just fix the "other" drive to an unused mapping? "R:" or something?

If you really want to go down the random drive mapping route, do it this way:
  • Assign all possible letters to a variable.
  • Use the left-most letter to map the drive
  • Strip the letter that you have just used off the string so that it won't be used for the next mapping


Here is a simple example of how to do it (untested). Drive mappings will be assigned to drives Q:, R:, S: and T: in the order that they appear in the script. If you should run out of letters, the mapping will be assigned to the first unused drive letter:
Code:
Dim $sDrives


$sDrives="Q:R:S:T:"

If InGroup("group a")
MapDrive(Left($sDrives,2),"\\some\share")
$sDrives=SubStr($sDrives,3)
EndIf

If InGroup("group b")
MapDrive(Left($sDrives,2),"\\some\other share")
$sDrives=SubStr($sDrives,3)
EndIf


Function MapDrive($sDriveLetter,$sSharePath)
If $sDriveLetter
; Delete existing mapping
Use $sDriveLetter /delete /persistent
; *** Add error checking here ***
Else
$sDriveLetter="*" ; No drive letter - select one at random
EndIf
; Create new mapping
Use $sDriveLetter $sSharePath
; *** Add error checking here ***
EndFunction


Top
#120426 - 2004-06-01 01:44 PM Re: mapping drives to different letters
Adams Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 6
yep, that's another way I considered, but there seems to be no pattern to which 2 departments someone could be in, which would mean I'd have to write if statements for every possible combination to be sure I caught them all, which would get very messy, but thx for offering the idea
Top
#120427 - 2004-06-01 02:02 PM Re: mapping drives to different letters
Adams Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 6
setting the alternate drive to a fixed letter would be fine, assuming someone is only ever in 2 groups, which is the case so far.

code like:

Code:
  
If in group X
Map Q: \share
EndIf

If in group Y & Q is taken
Map R: \othershare
EndIf



That would work I guess but I don't know the syntax for that in kix, another way my logic tells me I could do it in programming terms is:

Code:
  
If in group X
Map Q: \share
ingroup = 1
EndIf

If in group Y & ingroup = 1
Map R: \othershare
EndIf



so a simple boolean variable, but again, I don't know how to do this (or if it's possible) in kix, it's frustrating but then I've only been using kix a few days so far. guess I'll learn more as go.

the random letter script idea, I could try that but if it's easier to just to use a fixed letter I think that would keep the script a lot simpler.

thank for all the input by the way, I do appreciate it.

Top
#120428 - 2004-06-01 02:07 PM Re: mapping drives to different letters
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Did you consider mapping Q: to the DeptData share and having ALL departments listed under this share? then you would only need to make one mapping to Q: and they could access the folders of both departments.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#120429 - 2004-06-01 02:14 PM Re: mapping drives to different letters
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The script I provided does not use random letters (unless it runs out!).

The first mapping will always be made to "Q:", the second will always be "R:", the third to "S:" and so-on. These are mapped in the order that they are encountered in the script.

This solution fits your needs exactly, and will scale to any number of groups (unless you run out of letters!)

Your only issue is ordering the mappings in the script so that the right drive gets mapped to Q:

FWIW I have a similar issue which means that I am changing our methodology to a single drive mapping with all department directories visible, and using permissions to control access. This creates some headaches - mainly with templates - but is far simpler in the end.

Top
#120430 - 2004-06-01 02:20 PM Re: mapping drives to different letters
Adams Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 6
hmm, definately worth considering, I'll have a word with my boss and see what he thinks, would mean I'd have to redo all the shares but once it's done it would save a lot of hassle

I'd still appreciate an answer though if anyone knows how in case my boss says no (for whatever reason), and for personal curiosity in case I have to do anything similar in future.


Top
#120431 - 2004-06-01 02:25 PM Re: mapping drives to different letters
Adams Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 6
just read your original post again Richard, and you're right sorry, I misinterpreted what you meant. just looked at your script again and though I don't really understand everything that's going on (though I will soon hopefully) I can see what it's trying to achieve, I'll play about with it and see what I can come up with, thanks.
Top
#120432 - 2004-06-01 02:33 PM Re: mapping drives to different letters
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
there is a mapdrive UDF that you can pass a list of letters and if it fails to map the first, it will map the second, etc

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=82343&page=42&view=collapsed&sb=3&o=all&fpart=1
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#120433 - 2004-06-02 05:09 AM Re: mapping drives to different letters
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I was already wondering how long it would take until somebody would point out the various MapDrive() UDFs that are posted in the UDF Forum.
_________________________
There are two types of vessels, submarines and targets.

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
0 registered and 1183 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.071 seconds in which 0.047 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