Page 1 of 1 1
Topic Options
#21775 - 2002-05-17 05:39 PM installing printers
bluesteel Offline
Fresh Scripter

Registered: 2002-05-13
Posts: 32
Loc: Montreal, Quebec Canada
hi all again,

i want to add printers in the login script using kixtart. I want to first check what group the

user is in, if he is in the right group to then install the printer(s) only if not already there.

Now, do i need nested ifs for this, or is there an easier way?

I thought i had something, but now im just drawing a blank.

thx
blue

[ 17 May 2002, 17:39: Message edited by: bluesteel ]

Top
#21776 - 2002-05-17 05:44 PM Re: installing printers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The simplest solution is
code:
IF INGROUP('Group_A')
$rc=ADDPRINTERCONNECTION('\\server\printer')
ENDIF

with an IF clause for each distinct group-printer combination. Of cource, one can combine multiple groups with AND or OR in the condition.
You can get more fancy by checking the registry for printers that the user already mapped and only map those that do not yet exist, but I'd just skip that part since the end result would be the same.
_________________________
There are two types of vessels, submarines and targets.

Top
#21777 - 2002-05-17 05:56 PM Re: installing printers
bluesteel Offline
Fresh Scripter

Registered: 2002-05-13
Posts: 32
Loc: Montreal, Quebec Canada
thx alot....thats what i figured.....but then i was getting confused trying to incorporate to many ifs........thx again
Top
#21778 - 2002-05-17 06:06 PM Re: installing printers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It depends how many printers you have. what I am doing is create a .INI file that lists the printer and the groups that map to that printer. I then loop through the printer list and check whether that particular user is part of a group that need the printer mapped. Sounds complicated but in the end you have soemthing like 15 lines of code plus the .INI file.
Here's an example:
code:
; PRINTERS.INI
[Printer1]
Server=Server1
Groups=GroupA, GroupB

code:
$printers=readprofilestring('printers.ini','','')
for each $printer in $printers
$mapprinter=0
$groups=readprofilestring('printers.ini',$printer,'Groups')
$groups=split($groups,',')
for each $group in $groups
if ingroup($group)
$mapprinter=1
endif
next
if $mapprinter
$server=readprofilestring('printers.ini',$printer,'Server')
$rc=addprinterconnection('\\'+$server+'\'+$printer)
endif
next

_________________________
There are two types of vessels, submarines and targets.

Top
#21779 - 2002-05-21 08:10 AM Re: installing printers
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Nice...

But does anyone know how to do this trick with Win95 machines????
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#21780 - 2002-05-21 10:38 AM Re: installing printers
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
For W2K it's no problem, but for Win'95 it is. We programmed two Delpho programs who installs the printers for you, cause in Kix it wasn't possible to do this. What we do is:
- copy all printerdrivers to the Win'95 machine.
- copy the latest msprint.inf (the Delphi program uses this file to see what driver is used)
- copy specific printer definition files to a location on the workstation. These are simple text files, containing the queue, the driver, comment and sometimes also hex info.
- run the first Delphi program, which deletes all the printers.
- run the printer installation Delphi program.

Again: i dont think Kix can do this for Win'95 [Frown]
_________________________
Kind regards,

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

Generated in 0.055 seconds in which 0.027 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