Page 1 of 1 1
Topic Options
#122740 - 2004-07-13 10:40 AM Mapping printers based on computer name.
JE147 Offline
Lurker

Registered: 2004-07-12
Posts: 3
Hi all!

I have not used kixstart at all and need help to make a script for mapping printers based on what computername you have. Does anyone have a script i can use for this? Need help right now!

Thanks

Johan Eriksson

Top
#122741 - 2004-07-13 11:18 AM Re: Mapping printers based on computer name.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
look in the manual for @wksta and addprinterconnection()
_________________________
!

download KiXnet

Top
#122742 - 2004-07-13 11:38 AM Re: Mapping printers based on computer name.
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Also use the search facility on this board.

Attaching printers based on location or machine name is a common requirement, and has been dealt with here frequently.

Review the searches, and use the method that best suits your requirements.

Top
#122743 - 2004-07-13 11:54 AM Re: Mapping printers based on computer name.
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
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


Top
#122744 - 2004-07-13 12:12 PM Re: Mapping printers based on computer name.
JE147 Offline
Lurker

Registered: 2004-07-12
Posts: 3
Hi!

Thanks for your speedy response. I have located the UDF but since i have not used Kixtart,UDF i dont know how to use UDF. Can you explain to me?

Top
#122745 - 2004-07-13 12:18 PM Re: Mapping printers based on computer name.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
like my first response reflected, you shouldn't go there.
just read your manual on the given keywords.
you will not need any UDF's nor higher understanding of kixtart nor any other language.
_________________________
!

download KiXnet

Top
#122746 - 2004-07-13 03:44 PM Re: Mapping printers based on computer name.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Breaker,
Did you know there is an easier way to populate arrays?
$Desk1 = "corpdr6186", "corpdr6240", "corpdr6288", "corpdr6289"
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122747 - 2004-07-13 04:24 PM Re: Mapping printers based on computer name.
JE147 Offline
Lurker

Registered: 2004-07-12
Posts: 3
Hi Lonkero!

I have tested this:

--------------------------
SELECT

CASE LEFT(@WKSTA,5) = "NAVEL"
Addprinterconnection("\\sturehofpdc\HP LaserJet 2200 Series PCL 6") =0
Addprinterconnection("\\sturehofpdc\HP LaserJet 5000 Series PCL 6") =0
SetDefaultPrinter("\\sturehofpdc\HP LaserJet 2200 Series PCL 6") =0

CASE LEFT(@WKSTA,5) = "???"
Addprinterconnection("\\sturehofpdc\HP LaserJet 2200 Series PCL 6") =0
Addprinterconnection("\\sturehofpdc\HP LaserJet 5000 Series PCL 6") =0
SetDefaultPrinter("\\sturehofpdc\HP LaserJet 2200 Series PCL 6") =0

ENDSELECT

------------------

This seems to work ok. Can you please give me suggestions if needed.

Thanks

/Johan Eriksson

Top
#122748 - 2004-07-13 09:02 PM Re: Mapping printers based on computer name.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, basically it's ok.
instead of:
Addprinterconnection("...") =0

should use something like:
$trash = Addprinterconnection("...")

and one word about difference between addprinter and setdefault.
addprinterconnection takes parameter \\server\printershare and setdefaultprinter takes \\server\printerNAME

that's the thing that has got many confused.
_________________________
!

download KiXnet

Top
#122749 - 2004-07-14 04:50 PM Re: Mapping printers based on computer name.
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
Les,

Yeah, I know that. However, I don't think all of my colleagues do, and since we have a shared responsibility to maintain the scripts and the DR site itself, the layout of the script is more important - lots of whitespace so that people can see blocks of text = banks of desks!

I do use the other syntax in some of my scripts, it really depends on how many other people may have to read/edit/maintain it in my absence, or without my knowledge.

[Sigh]
_________________________
================================================
Breaker


Top
#122750 - 2004-07-14 09:41 PM Re: Mapping printers based on computer name.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, I think the shorter way is even easier to understand.
_________________________
!

download KiXnet

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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.067 seconds in which 0.032 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