#199118 - 2010-07-26 11:27 PM
Drive mapping depending on workstation
|
choey
Fresh Scripter
Registered: 2007-12-03
Posts: 5
|
I am currently using CASE @ LSERVER = "servename" so clients get drive mappings depending on the the server they logon to.
Ex: Case @LServer = '\\ps01-fs1' Or @LServer = '\\ps01-fs2' use g: '\\ps01-fs1\apps' use r: '\\ps01-fs1\resources'
Case @LServer = '\\ps02-fs1' Or @LServer = '\\ps02-fs2' use g: '\\ps02-fs1\apps' use r: '\\ps02-fs1\resources'
Now I would like the drive mappings to depend on the workstation they logon to, instead of the server. All our workstation names are prefixed for the building they are in, ex: ps12-room1-01, ps13-room2-03, ps14.
Is there a wildcard I can use with the wksta command? an someone please provide me with the proper syntax?
Thank you, Chris
|
|
Top
|
|
|
|
#199119 - 2010-07-26 11:57 PM
Re: Drive mapping depending on workstation
[Re: choey]
|
eriqjaffe
Hey THIS is FUN
Registered: 2004-06-24
Posts: 214
Loc: Arlington Heights, IL USA
|
You can use INSTR to look for value inside a string (or a macro).
Select
Case Instr(@WKSTA,"ps12")
; map drives for ps12
Case Instr(@WKSTA,"ps13")
; map drives for ps13
Case 1
; Default set of mapped drives for anything else
EndSelect
Edited by eriqjaffe (2010-07-26 11:59 PM)
|
|
Top
|
|
|
|
#199122 - 2010-07-27 03:49 PM
Re: Drive mapping depending on workstation
[Re: Richard H.]
|
choey
Fresh Scripter
Registered: 2007-12-03
Posts: 5
|
Thank you for your replies and please pardon my thickness. I'm confused between the 2 replies. I want any PC that starts with PS12 (the entire names would be ps12-client1, ps12-client2 and so on) to map specific drives. Would it be like the following?
Case Instr(@WKSTA,"ps12")=1 use g: '\\ps12-fs1\apps' use r: '\\ps12-fs1\resources'
Case Instr(@WKSTA,"ps13")=1 use g: '\\ps13-fs1\apps' use r: '\\ps13-fs1\resources'
Here is what I am currently using and it works great (I need to change to workstations though.
Case @LServer = '\\ps12-fs1' Or @LServer = '\\ps12-fs2' use g: '\\ps12-fs1\apps' use r: '\\ps12-fs1\resources' Case @LServer = '\\ps12A-fs1' Or @LServer = '\\ps12A-fs2' use g: '\\ps12A-fs1\apps' use r: '\\ps12A-fs1\resources'
Thank you all again
|
|
Top
|
|
|
|
#199124 - 2010-07-27 05:07 PM
Re: Drive mapping depending on workstation
[Re: choey]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Yes, that code will work fine.
The difference between the two responses is a subtle one.
Say you wanted to check for a machine that starts "FILE*", you could use
If InStr(@WKSTA,"FILE") ...
This will correctly match FILESRV001, FILESRV002 and so on. Unfortunately it will also match "BACKUPFILESERVER" and any other name which has the text FILE in it somewhere.
As you want to do a prefix match we just check that the matched string starts in position 1:
If InStr(@WKSTA,"FILE")=1 ...
The results are: InStr("FILESRV001","FILE") returns 1, so matches InStr("FILESRV002","FILE") returns 1, so matches InStr("BACKUPFILESERVER","FILE") returns 7, so does not match
|
|
Top
|
|
|
|
#199125 - 2010-07-27 06:52 PM
Re: Drive mapping depending on workstation
[Re: Richard H.]
|
choey
Fresh Scripter
Registered: 2007-12-03
Posts: 5
|
Mart's solution works beautifully - thank you very much to everyone.
Chris
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1046 anonymous users online.
|
|
|