Page 1 of 1 1
Topic Options
#111405 - 2004-01-07 04:55 PM Add printer to computer not to user
TheOneAndOnly Offline
Lurker

Registered: 2004-01-07
Posts: 3
I would like to connect printers based on computernames and not users. How do I do that?
I tried the ingroup function but this does not seems to work.



Top
#111406 - 2004-01-07 05:04 PM Re: Add printer to computer not to user
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You will have to do this by installing the printer as a local printer not a network printer. However, why would you want to do this? Updating/changing printers/drivers will be an administrative nightmare. Printers should be installed as network printers with a print server to which users that need access to that particular printer can connect. Exception are directly-attached printers that are dedicated to a particular computer or physical location (e.g. office).

Or do you want to connect to networked printers based on the computername and not the username?


Edited by sealeopard (2004-01-07 05:16 PM)
_________________________
There are two types of vessels, submarines and targets.

Top
#111407 - 2004-01-07 05:08 PM Re: Add printer to computer not to user
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You will need to supply much more information to get a decent answer.

Here's a short list of things you should start with:
  • Version of KiXtart
  • Operating systems of servers and clients
  • Number of sites
  • Computer and printer names
  • IP address schema


There are quite a few scripts already on the board for assigning printers by location. Use the search facility to search the "starters" and "script" forums - this may turn up something which already matches your requirements.

Top
#111408 - 2004-01-07 05:51 PM Re: Add printer to computer not to user
TheOneAndOnly Offline
Lurker

Registered: 2004-01-07
Posts: 3
I'm using Kixtart version 4.22 with windows 2000 servers and windows xp clients. There is only one site and the ip-adres range is 192.168.1.1
Top
#111409 - 2004-01-07 05:55 PM Re: Add printer to computer not to user
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I guess the simplest way would be
Code:

select
case @WKSTA='comp1'
$rc=addprinterconnection('\\server\printer1')
caes @WKSTA='comp2'
$rc=addprinterconnection('\\server\printer2')
case 1
endselect

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

Top
#111410 - 2004-01-07 06:07 PM Re: Add printer to computer not to user
TheOneAndOnly Offline
Lurker

Registered: 2004-01-07
Posts: 3
Ok. that is a solution. But what if I want to use groups in windows 2000.

for example I make 2 worktations member of a windows 2000 group let's name the group sience then if the workstation is a member of that science group only then the printer should be installed on the computer.

Top
#111411 - 2004-01-07 06:15 PM Re: Add printer to computer not to user
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Then use for example the InContainer() UDF.
_________________________
There are two types of vessels, submarines and targets.

Top
#111412 - 2004-01-19 11:03 AM Re: Add printer to computer not to user
andyb7274 Offline
Lurker

Registered: 2002-05-26
Posts: 2
I had the same problem, when I had to add specific printers relevant to the classroom they are located, I managed after a lot or trial and error to come up with this.

;This function will accept the 3 parameters to add the printers
;The three parameters are $min=lowest numbered computer in the room
;$max is the highest numbered computer in the room
;$printer is the actual printer to be added


function Addprinter($min,$max,$printer)
for $count=$min to $max step 1
$class="$room"+"$count"
if instr($class,@wksta)
addprinterconnection("$printer")
endif
next
endfunction

;Example of workstation based PC's (bear in mind our pc's are named with a letter then a number, for example B1515)


List of printers served by printserver
;----------
$prtserver="\\keep"
;----------

$b21print="$prtserver\b21print"
$b23print="$prtserver\b2307"
$dtprint="$prtserver\dtprinter"
$b8printer="$prtserver\b8printer"
$b16laser="$prtserver\b16laser"
$b15printer="$prtserver\b15printer"
$b16colour="$prtserver\b16colour"
$6thformxerox="$prtserver\6thformxerox"
$libxerox="$prtserver\libxerox"
$a13print="$prtserver\a13print"
$hpfood="$prtserver\hpfood"
$it="$prtserver\itroom"
$artxerox="$prtserver\artxerox"
$fiery="$prtserver\fiery"
$l4="$prtserver\l4print"
$b6xerox="$prtserver\b4xerox"
$geogprint="$prtserver\geogprint"
$english="$prtserver\english"
$c2samsung="$prtserver\c2samsung"

Example of printer being added by computername

dim $class[14]
$room="b"
addprinter(2101,2115,$b21printer)

Hope this helps
_________________________
--
Regards

Top
#111413 - 2004-01-20 07:48 PM Re: Add printer to computer not to user
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
After much work and assistance from users her, I have a script that adds printers to computers based upon computer groups. Search the Starters forum for more details.

I had the printer names already defined by q-<name> format in my domain. (I used a kix script to create all the corresponding group names in the format of A01_<printername> and D01_<printername>. If you are interested in this script, let me know.)

To save login time for those users not receiving printers based upon group membership, I created an additional group called Printer Setup Group and added the workstations to this group that will be receiving printers based upon group membership and call the script printers.kix that I am posting here only if workstations are in this first group. I use the function ComputerInGroup.udf to determine if workstations are in the Printer Setup Group, for example, in my kixtart.kix login script I include the following:

Code:

if ComputerInGroup ('Printer Setup Group')=1
call @ScriptDir+'\printers.kix'
endif



This script will not work for Windows 95. Note that it calls the function PriMapState.udf.

Syntax of names:

Printer names = <q-name>

Computer Group names for default printer = D01_<printername>

Computer Group names for add'l printer = A01_<printername>

Print Server name = srv-01 (specified by variable ps1$)

For example, to add default printer q-printer1 and additional q-printer2 shared on server srv-01 to a computer named computer1:

1. Printers shared from server srv-01 = \\srv-01\q-printer1 and \\srv-01\q-printer2
2. Create a group called D01_q-printer1
3. Create a group called A01_q-printer2
4. Add computer1 to both groups
5. Login from computer1

If the printers do not exist, they will be added as q-printer1 as default and q-printer2 as additional. If they exist but wrong the one is default, it will be changed to printer as specified by D01_ group.

Printers.kix
Code:

;********** Beginning of printer mapping *********
$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")

if @error
? @serror
else

$ps1="srv-01"

for each $grp In $WS.Groups
$GrpName = $grp.Name

;--- Add additional printers ---

if left($GrpName,4) = "A01_"
$addlprinter = substr($GrpName,5)
$addlprinter = $ps1+"\"+$addlprinter
$addlprinter = "\\"+$addlprinter
? "Additional Printer: "$addlprinter

if not PriMapState($addlprinter)
? "Status: Printer not connected " + $addlprinter
$S=AddPrinterConnection($addlprinter)
? "Status: Printer added: " + $addlprinter
? @serror ?

endif

endif

;--- Add and set default printer ---

if left($GrpName,4) = "D01_"
$defprinter = substr($GrpName,5)
$defprinter = $ps1+"\"+$defprinter
$defprinter = "\\" + $defprinter
? "Default Printer: "$defprinter

if not PriMapState($defprinter)
? "Status: Printer not connected "+$defprinter
$nul=AddPrinterConnection($defprinter)
? "Status: Printer added "+ $defprinter
? @serror ?
$nul=SetDefaultPrinter($defprinter)
? "Status: Default Printer set: " +$defprinter
? @serror ?
endif

if PriMapState($defprinter)<>2
$nul=SetDefaultPrinter($defprinter)
? "Status: Default Printer set: " + $defprinter
? @serror ?
?
endif

endif

next

endif

;FUNCTION PriMapState v1.1
;
;AUTHOR Lonkero (Jooel.Nieminen@gwspikval.com)
;
;ACTION Checks for existent networkprinter connection
;
;SYNTAX PriMapState(PRINTER)
;
;PARAMETERS PRINTER
; Printers name to be checked
;
;RETURNS 1 if printer connected
; 2 if printer is default
; nothing if not connected
;
;REMARKS code for w9x adapted from BrianTX
;
;DEPENDENCIES none
;
;EXAMPLE if not PriMapState('\\server\printer1')
; "printer not connected!"
; endif
;
;CODE
function PriMapState($_Pri)
if @inwin=1
if len(readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices",$_Pri))
if split(readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0]=$_Pri
$PriMapState=2
else
$PriMapState=1
endif
endif
else
dim $_Root,$_C,$_C2 $_Root="HKLM\System\CurrentControlSet\control\Print\Printers"
for $_C=0 to 259
$_C2=enumkey($_Root,$_C)
If instr(READVALUE($_Root+"\"+$_C2,"Port"),$_Pri)
If instr(READPROFILESTRING("%windir%\win.ini","windows","device"),$_Pri)
$PriMapState = 2
Else
$PriMapState = 1
Endif
Endif
if $_C2=259 $_C=$_C2 endif
next
endif
endfunction




Edited by tjcarst (2004-01-20 08:14 PM)

Top
#111414 - 2004-01-20 08:03 PM Re: Add printer to computer not to user
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Quote:

$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")



Is ADSI installed on the Windows 9x machine?
_________________________
There are two types of vessels, submarines and targets.

Top
#111415 - 2004-01-20 08:11 PM Re: Add printer to computer not to user
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
No - it is not. I plan on installing the new Directory Services Client in the next month or so.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;323466

Will this script work for 95 if ADSI is installed? They can browse AD if I install the DS Client, but they have no computer account in AD.

I thought SETDEFAULTPRINTER and ADDPRINTERCONNECTION were incompatible with 95. PRIMAPSTATE/PRIMAPSTATE95 will work.

*edited to clarify AD and the items incompatible with 95

Top
#111416 - 2004-01-20 09:19 PM Re: Add printer to computer not to user
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The script you posted requires ADSI. Therefore, if the ADS client is not installed on the Windows 9x computer, the script will not work.
_________________________
There are two types of vessels, submarines and targets.

Top
#111417 - 2004-01-20 09:22 PM Re: Add printer to computer not to user
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Even with ADSI installed, Wintendos cannot add printers.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#111418 - 2004-01-20 09:23 PM Re: Add printer to computer not to user
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Ah, details, details,...
_________________________
There are two types of vessels, submarines and targets.

Top
#111419 - 2004-01-20 09:30 PM Re: Add printer to computer not to user
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
In my original post I did state that it did not support Win95. I use OSID to determine if 95 or anything other than a workstation and exit printer script. Adding printers to Win95 computers really isn't needed by me in the healthcare organization where I work. Once the first printer is installed for a Win95 user, all users that signon to that computer get the printer. Not so with NT and above, each user gets a profile created at startup that does not include network printers. We are moving away from shared signons (that have the printers defined) and each user must now signon to the network. This creates major problems when there are hundreds of nurses & therapists that could signon to the shared computers.

So, the script won't work for everyone, but works for me.

You had me wound up there for a minute.

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 774 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.069 seconds in which 0.026 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