Page 1 of 1 1
Topic Options
#140217 - 2005-05-24 06:19 PM Assigning Printers by Geographical Location
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
Good Morning All,

I am beginning to create a kix script for assigning printers to my users. I was wondering if anyone has done this based on geographical location.

My network is setup were all computer names start with a department acronym. i.e. Finance = FI, Engineering = EN, etc.

It would be neat if I could assign default printers based on the first two characters of a computer name. This would insure that all users logging into a department computer would have the closest printer mapped as the default.

Does anyone have a suggestion?

Thanks, Matt

Top
#140218 - 2005-05-24 06:34 PM Re: Assigning Printers by Geographical Location
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
That can definitely be done. Just as a start you could do something like

Code:

if left(@wksta,2) = 'FI'
; Finance Printer
endif



And i know a lot of people base their printer mapping off of ini files, so you could step it up a notch and have an ini file like maybe

Printers.ini
Code:

[FI]
DefaultPrinter=TheFinancePrinter
SecondaryPrinter=ABackupPrinterMaybe
[EN]
DefaultPrinter=TheEngineeringPrinter
SecondaryPrinter=TheirBackupPrinter



And then in your script something like

Code:

$dept = left(@wksta,2)
$defPrinter = readprofilestring("PathToIni",$dept,"DefaultPrinter")
$secPrinter = readprofilestring("PathToIni",$dept,"SecondaryPrinter")



I'm sure others here can provide more (better?) suggestions...

Top
#140219 - 2005-05-24 07:05 PM Re: Assigning Printers by Geographical Location
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Is there a particular reason why you would post a starters question in the General Discussions forum?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#140220 - 2005-05-24 07:12 PM Re: Assigning Printers by Geographical Location
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
Quote:

"Pedro, how do you feel about that one? That looks pretty sweet, that looks awesome, that script it's.... it's incredible....."




I haven't used ini files before, but that looks great. I'll start chewing on it and see if I can make it work. THANKS!

Top
#140221 - 2005-05-24 07:14 PM Re: Assigning Printers by Geographical Location
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
Yeah, all the nice people are answering my questions. But, I can move it if needed.
Top
#140222 - 2005-05-24 07:37 PM Re: Assigning Printers by Geographical Location
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The same nice people answer questions in the "Starters" forum too. The Starters forum is a better fit and we prefer that basic KiX questions be posted there. It helps to keep them somewhat categorized for searching later.

Thanks for understanding
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#140223 - 2005-05-24 08:02 PM Re: Assigning Printers by Geographical Location
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
Quote:

That can definitely be done. Just as a start you could do something like

Code:

if left(@wksta,2) = 'FI'
; Finance Printer
endif



And i know a lot of people base their printer mapping off of ini files, so you could step it up a notch and have an ini file like maybe

Printers.ini
Code:

[FI]
DefaultPrinter=TheFinancePrinter
SecondaryPrinter=ABackupPrinterMaybe
[EN]
DefaultPrinter=TheEngineeringPrinter
SecondaryPrinter=TheirBackupPrinter



And then in your script something like

Code:

$dept = left(@wksta,2)
$defPrinter = readprofilestring("PathToIni",$dept,"DefaultPrinter")
$secPrinter = readprofilestring("PathToIni",$dept,"SecondaryPrinter")



I'm sure others here can provide more (better?) suggestions...




maciep,

I have a question about your script:

You identify $defPrinter as readprofilestring("PathToIni",$dept,"DefaultPrinter").

Would I then use the $defPrinter variable like this:
Code:
 ADDPRINTERCONNECTION ("$defPrinter") 


Top
#140224 - 2005-05-24 08:26 PM Re: Assigning Printers by Geographical Location
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Yes if the value in your ini file is the sharename of the queue (I think). But honestly, i haven't done much (if anything) with adding printer connections, so maybe someone more versed in the area could field this one.

I do know, however, that you do not need the quotes around variable. And in general, using variables in strings is considered poor coding technique.

Top
#140225 - 2005-05-24 08:56 PM Re: Assigning Printers by Geographical Location
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
Okay.... I created a script that works. Please look it over and let me know if I need to modify how the script runs.

User logs in and runs logon.kix which makes the following call:
Code:
 CALL @SCRIPTDIR+'\printers.kix' ; This script assigns printers to client logon profiles. 



The contents of printers.kix runs:
Code:
 $dept = left(@wksta,2)
$1stPrinter = readprofilestring("\\data\netlogon\printers.ini",$dept,"1stPrinter")
$2ndPrinter = readprofilestring("\\data\netlogon\printers.ini",$dept,"2ndPrinter")
$3ndPrinter = readprofilestring("\\data\netlogon\printers.ini",$dept,"3ndPrinter")
IF AddPrinterConnection ($1stPrinter) = 0
? "Added printer connection...."
ENDIF



Which parses the printers.ini:
Code:
 [AB]
1stPrinter=\\DATA\FDAMBLJ
2NDPRINTER=\\DATA\FDADMINLJ
3RDPRINTER=\\DATA\FDCOLORLJ

[AQ]
1STPRINTER=\\DATA\AQOFFICELJ
2NDPRINTER=\\DATA\AQCOLORLJ

[BU]


[CC]
1STPRINTER=\\DATA\CCADMINLJ
2NDPRINTER=\\DATA\CCOFFICELJ
etc.........



My end result being: Printers are added to computers according to their departments. If the printer exists, the process is aborted.

Any corrections are appreciated.

Thanks, Matt


Edited by Huffinagle (2005-05-24 11:02 PM)

Top
#140226 - 2005-05-24 09:10 PM Re: Assigning Printers by Geographical Location
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
The script you posted is still using that $defPrinter variable from my earlier example, but it looks like you should be using $1stPrinter instead now, right?
Top
#140227 - 2005-05-24 10:45 PM Re: Assigning Printers by Geographical Location
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
Thanks for catching that. Here's an updated Code:

Code:
 
$dept = left(@wksta,2)
$1stPrinter = readprofilestring("\\city1\netlogon\printers.ini",$dept,"1stPrinter")
$2ndPrinter = readprofilestring("\\city1\netlogon\printers.ini",$dept,"2ndPrinter")
$3ndPrinter = readprofilestring("\\city1\netlogon\printers.ini",$dept,"3ndPrinter")
IF AddPrinterConnection ($1stPrinter) = 0
? "Added printer connection...."
ENDIF
IF AddPrinterConnection ($2ndPrinter) = 0
? "Added printer connection...."
ENDIF
IF AddPrinterConnection ($3rdPrinter) = 0
? "Added printer connection...."
ENDIF


Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.071 seconds in which 0.034 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