Page 1 of 1 1
Topic Options
#7986 - 2001-04-05 03:34 PM Mapping Drive by first two char of computer name.
Anonymous
Unregistered


Can you map a drive by first two char of computer name.
Problem:
I control three different sites with users that move between all three sites. I would like to map there drives based on the first two char. of the computer name.
For example:
computer name DC1234 = map G to local DC server.
OR
computer name VA1234 = map G to local VA server.

Thanks in advance.
william_ross@gensler.com

Top
#7987 - 2001-04-05 04:33 PM Re: Mapping Drive by first two char of computer name.
Anonymous
Unregistered


Hi William,

Here's one way to map your drives using the PC name:

code:

BREAK ON CLS

$PCNAME=@WKSTA

SELECT
CASE INSTR ($PCNAME, "DC")
USE G: "\\SERVER1\SHARE"
CASE INSTR ($PCNAME, "VA")
USE G: "\\SERVER2\SHARE"
CASE 1
? "Non standard PC name.."
ENDSELECT



Top
#7988 - 2001-04-05 04:40 PM Re: Mapping Drive by first two char of computer name.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Using SUBSTR() would be better then using INSTR()

code:

select
case substr(@wksta,1,2) = "DC"
...
case substr(@wksta,1,2) = "VA"
...
case 1
...
endselect


Bryce

------------------
kix.isorg.net

[This message has been edited by Bryce (edited 05 April 2001).]

Top
#7989 - 2001-04-05 10:04 PM Re: Mapping Drive by first two char of computer name.
Anonymous
Unregistered


Thanks for the help!!! I get it now....
Top
#7990 - 2001-04-06 04:29 PM Re: Mapping Drive by first two char of computer name.
Anonymous
Unregistered


Bryce,

Could you please explain why the SUBSTR command would be a better choise than INSTR ?

Bert.

Top
#7991 - 2001-04-06 04:52 PM Re: Mapping Drive by first two char of computer name.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
The SUBSTR() command can grab just the first 2 letters of the string.

The INSTR() command searches the entire string looking for those 2 letters.

Take the following code

code:

BREAK ON CLS

$PCNAME="VA123DC"

SELECT
CASE INSTR ($PCNAME, "DC")
USE G: "\\SERVER1\SHARE"
CASE INSTR ($PCNAME, "VA")
USE G: "\\SERVER2\SHARE"
CASE 1
? "Non standard PC name.."
ENDSELECT



Even though VA is the first 2 letters, the first case argument is proven true because you preform a INSTR() on the entire string looking for "DC" and $pcname = "VA123DC"

using SUBSTR() removes the chance of that happening.

Bryce

------------------
kix.isorg.net

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 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.057 seconds in which 0.03 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