Page 1 of 1 1
Topic Options
#69255 - 2002-08-21 02:36 PM Printing Scripts
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hi all

I have created a printer script that works out what workstation you are working on then sets up the printers, and the option of having your office printer to follow you about.

This might be useful users who move around alot and do not have a dedicated PC.

First of all I run a Computer Startup Script.

;Computer Boot-Up Printer Script

; This line sets the variable $prn to the prnfile.ini file which contains all the workstation names
$prn = "\\QEH-TR\SYSVOL\QEH-TR.STHAMES.NHS.UK\Scripts\prnfile.ini"

$prn1 = READPROFILESTRING("$prn", @wksta, "prn1")
$prn2 = READPROFILESTRING("$prn", @wksta, "prn2")
$defprn = READPROFILESTRING("$prn", @wksta, "default")

open ( 1 ,"%SystemDrive%\Printers.cmd" , 5 )
writeline ( 1 , "\\QEH-TR\SYSVOL\QEH-TR.STHAMES.NHS.UK\SCRIPTS\con2prt /f " +$defprn + " " +$prn1 + " " +$prn2)
close (1)

That references a ini file which looks like this:

[DCENTRE01]
prn1 = /c \\fileprint\3341
;prn2 = /c \\fileprint\3343
default = /cd \\fileprint\3340

[DCENTRE02]
prn1 = /c \\fileprint\3341
;prn2 = /c \\fileprint\3340
default = /cd \\fileprint\3340

[DCENTRE03]
prn1 = /c \\fileprint\3341
;prn2 = /c \\fileprint\3340
default = /cd \\fileprint\3340

Then when the user logs in, the login script will call the printers.cmd file located on the local PC and connect to the 3 nerest printers to that PC.

And the as a optional script, If a user want their Office printer on the printer list I run this script.

;Home Printer Re-Direction Script

$prn = @LDRIVE + "homeprn.ini"

$homeprn = READPROFILESTRING("$prn", @userid, "homeprn")

shell @LDRIVE + "con2prt /c " +$homeprn"

That calls a ini file which looks like this.

[administrator]
homeprn = \\fileprint\opsptr

[richard.farthing]
homeprn = \\fileprint\3044

[tracy.ross]
homeprn = \\fileprint\3341

I work for a Hospital, and this has worked wonders since installing.

Hope it can help someone out.

Richard Farthing

Top
#69256 - 2002-08-21 04:00 PM Re: Printing Scripts
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
See also
code:
;-------------------------------------
; map printers based on user groups
;
; Structure of the .INI file:
; [Printer name]
; Printserver = Name of the printserver (might be comma-delimited for redundancy)
; GroupInclude = User groups to be included in the printer connection
; CompExclude = Computers to be excluded from the drive share
; UserInclude = Users to be included in the drive share
; Model = Model of the printer
;-------------------------------------
; UDFs: ATRIM(), ISINCLUDED(), MAPPRINTER()
:NETWORKED_PRINTERS
Dim $printerlist, $printername, $printserver, $printmodel
Dim $GroupInclude, $CompExclude, $UserInclude, $os, $rc

if @INWIN=1
if exist($PRINTERSINI)
? 'Connecting network printers'
$printerlist=readprofilestring($PRINTERSINI,'','')
$printerlist=atrim(split($printerlist,chr(10)))
for each $printername in $printerlist
if len($printername)
$GroupInclude=readprofilestring($PRINTERSINI,$printername,'GroupInclude')
$GroupInclude=atrim(split($GroupInclude,','))
$CompExclude=readprofilestring($PRINTERSINI,$printername,'CompExclude')
$CompExclude=atrim(split($CompExclude,','))
$UserInclude=readprofilestring($PRINTERSINI,$printername,'UserInclude')
$UserInclude=atrim(split($UserInclude,','))

if isincluded($GroupInclude, $CompExclude, $UserInclude)
$printserver=readprofilestring($PRINTERSINI,$printername,'Printserver')
$printserver=atrim(split($printserver,','))
$printmodel=readprofilestring($PRINTERSINI,$printername,'Model')
$rc=mapprinter($printername,$printserver,$printmodel)
endif
endif
next
else
? 'Cannot open printer initialization file '+$PRINTERSINI
endif
else
? 'Automatic printer installation is not supported under '+@PRODUCTTYPE
endif
return

which is part of a modular login script to be found at Modular Login Script (long post, lots of code) and is also used as part of KiXtart Systems Management Server

[ 21. August 2002, 16:04: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.13 seconds in which 0.106 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