#120421 - 2004-06-01 11:10 AM
mapping drives to different letters
|
Adams
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
   
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
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
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
   
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
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
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
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.
|
|
Top
|
|
|
|
#120430 - 2004-06-01 02:20 PM
Re: mapping drives to different letters
|
Adams
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
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2924 anonymous users online.
|
|
|