Here's how I do it for our disaster recovery facility - based on which bank of desks a PC is in. It relies on the Ascan() and IsInArray() UDFs, which can be found on this board.
Code:
;Create arrays of the PC names on each desk - these must be edited if the physical layout changes!!
Dim $Desk1[3]
$Desk1[0] = "corpdr6186"
$Desk1[1] = "corpdr6240"
$Desk1[2] = "corpdr6288"
$Desk1[3] = "corpdr6289"
Dim $Desk2[8]
$Desk2[0] = "corpdr6188"
$Desk2[1] = "corpdr6200"
$Desk2[2] = "corpdr6202"
$Desk2[3] = "corpdr6204"
$Desk2[4] = "corpdr6192"
$Desk2[5] = "corpdr6190"
$Desk2[6] = "corpdr6208"
$Desk2[7] = "corpdr6206"
$Desk2[8] = "corpdr6284" ;Bloomberg PC
Dim $Desk3[7]
$Desk3[0] = "corpdr6223"
$Desk3[1] = "corpdr6221"
$Desk3[2] = "corpdr6239"
$Desk3[3] = "corpdr6237"
$Desk3[4] = "corpdr6222"
$Desk3[5] = "corpdr6220"
$Desk3[6] = "corpdr6238"
$Desk3[7] = "corpdr6236"
Dim $Desk4a[3] ;These will use DRPRT04
$Desk4a[0] = "corpdr6217"
$Desk4a[1] = "corpdr6214"
$Desk4a[2] = "corpdr6216"
$Desk4a[3] = "corpdr6215"
Dim $Desk4b[3] ;These desks will use the A3 printer (DRPRT05) as their default
$Desk4b[0] = "corpdr6213"
$Desk4b[1] = "corpdr6211"
$Desk4b[2] = "corpdr6212"
$Desk4b[3] = "corpdr6210"
Dim $Desk5[9]
$Desk5[0] = "corpdr6263"
$Desk5[1] = "corpdr6265"
$Desk5[2] = "corpdr6267"
$Desk5[3] = "corpdr6269"
$Desk5[4] = "corpdr6175"
$Desk5[5] = "corpdr6179"
$Desk5[6] = "corpdr6173"
$Desk5[7] = "corpdr6171"
$Desk5[8] = "corpdr6197" ;Harvey's office
$Desk5[9] = "corpdr6182" ;Reuters PC
Dim $Desk6[12]
$Desk6[0] = "corpdr6271"
$Desk6[1] = "corpdr6273"
$Desk6[2] = "corpdr6275"
$Desk6[3] = "corpdr6277"
$Desk6[4] = "corpdr6279"
$Desk6[5] = "corpdr6270"
$Desk6[6] = "corpdr6282"
$Desk6[7] = "corpdr6298"; Heidi PC ???
$Desk6[8] = "corpdr6180";Reuters PC
$Desk6[9] = "corpdr6285";Bloomberg PC
$Desk6[10] = "corpdr6240" ;Rates PCs
$Desk6[11] = "corpdr6241" ;These are positioned near IT but should
$Desk6[12] = "corpdr6242";print to the Treasury printer, DRPRT07.
Select
Case IsInArray($Desk1,@WKSTA)
$x = AddPrinterConnection("\\DRSERV01\DRPRT01")
Case IsInArray($Desk2,@WKSTA)
$x = AddPrinterConnection("\\DRSERV01\DRPRT02")
$x = AddPrinterConnection("\\DRSERV01\DRPRT08")
$x = SetDefaultPrinter("\\DRSERV01\DRPRT02")
Use lpt1: "\\DRSERV01\DRPRT02"
Use lpt2: "\\DRSERV01\DRPRT02"
Use lpt3: "\\DRSERV01\DRPRT08"
Case IsInArray($Desk3,@WKSTA)
$x = AddPrinterConnection("\\DRSERV01\DRPRT03")
Case IsInArray($Desk4a,@WKSTA)
$x = AddPrinterConnection("\\DRSERV01\DRPRT05")
$x = AddPrinterConnection("\\DRSERV01\DRPRT04")
$x = SetDefaultPrinter("\\DRSERV01\DRPRT04")
Case IsInArray($Desk4b,@WKSTA)
$x = AddPrinterConnection("\\DRSERV01\DRPRT05")
$x = AddPrinterConnection("\\DRSERV01\DRPRT04")
$x = SetDefaultPrinter("\\DRSERV01\DRPRT05")
Case IsInArray($Desk5,@WKSTA)
$x = AddPrinterConnection("\\DRSERV01\DRPRT06")
Case IsInArray($Desk6,@WKSTA)
$x = AddPrinterConnection("\\DRSERV01\DRPRT07")
Case 1
? "An error has occurred. Your PC is not listed in the configuration file."
Endselect
The limitation of this is that the file or arrays that define the locations and which PCs are at those locations have to be maintained. Or you need to define your computer naming scheme in a location-aware way, with some kind of prefix to define office, department, building - whatever your criteria happen to be.
In the case of my DR site, this was an easy way to go, because the machines do not move around. Even if the seating plans change the office layout will remain the same, so this method works no matter what the admin departments throw at me!
Hope this helps.
_________________________
================================================
Breaker