Page 1 of 1 1
Topic Options
#199118 - 2010-07-26 11:27 PM Drive mapping depending on workstation
choey Offline
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 Offline
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).

 Code:
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
#199121 - 2010-07-27 08:35 AM Re: Drive mapping depending on workstation [Re: eriqjaffe]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
Is there a wildcard I can use with the wksta command? an someone please provide me with the proper syntax?


No, KiXtart does not have any pattern matching built-in.

InStr() can be used as a "match anywhere" substitute as in the code provided above, but if you want to check for a prefix you should anchor to the front of the string:
 Code:
Select
Case Instr(@WKSTA,"ps12")=1
     ; map drives for ps12
Case Instr(@WKSTA,"ps13")=1
     ; map drives for ps13
Case 1
     ; Default set of mapped drives for anything else
EndSelect


Edited by Richard H. (2010-07-27 08:49 AM)

Top
#199122 - 2010-07-27 03:49 PM Re: Drive mapping depending on workstation [Re: Richard H.]
choey Offline
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
#199123 - 2010-07-27 04:15 PM Re: Drive mapping depending on workstation [Re: choey]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
If it is always the first four characters in the workstation name that you need to check then this should do the trick.
 Code:
Select
	Case Left(@WKSTA, 4) = "ps12"
		Use g: '\\ps12-fs1\apps'
		Use r: '\\ps12-fs1\resources'
	Case Left(@WKSTA, 4) = "ps13"
		Use g: '\\ps13-fs1\apps'
		Use r: '\\ps13-fs1\resources'
EndSelect
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#199124 - 2010-07-27 05:07 PM Re: Drive mapping depending on workstation [Re: choey]
Richard H. Administrator Offline
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
 Code:
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:
 Code:
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 Offline
Fresh Scripter

Registered: 2007-12-03
Posts: 5
Mart's solution works beautifully - thank you very much to everyone.

Chris

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 884 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.114 seconds in which 0.09 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org