Page 1 of 2 12>
Topic Options
#186906 - 2008-04-14 11:39 PM adding printers
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA
Guys,

I like to add some printers to a few selected users. Basicially some users will get some printers (not all user will have the same printers)

They are not in any group, but I like to deploy it using GPO logon script under the user catgegory.

Can you provide the basic of the script.

The reason I am doing this instead of a script on each user's profile is we not using script to push printer out in past years. This is just a temporary pushed at this time.

I need command that allows me to specify each user (something like case select..)

tnt


Edited by Tony (2008-04-15 12:52 AM)

Top
#186908 - 2008-04-15 12:34 AM Re: adding printers [Re: Tony]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sure. Setting them based on group membership would be way easier to maintain but the example below will give you and idea how to do this without groups. This is just one way and I’m sure there are more options.

 Code:
$users = "usera","userb","userc"

If ASCAN($users, @USERID)
	$rc = AddPrinterConnection("\\server\printer")
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#186909 - 2008-04-15 02:16 AM Re: adding printers [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Don't forget to add code to check and make sure the printer is not already installed. No since in trying to install it on every logon.
Top
#186939 - 2008-04-15 10:55 PM Re: adding printers [Re: NTDOC]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA

Thanks a lot you guys. In the past, I have used Ingroup, but this situation calls for user basis.

Btw, our environment consists of XP Pro. Does kixtart install any temporary files on the workstation in order to run the script. Just wondering about write issue with windows. My co worker thinks there is a file being installed on clien'ts machine.


I will report back.

Tnt.


Edited by Tony (2008-04-15 10:58 PM)

Top
#186943 - 2008-04-16 01:37 AM Re: adding printers [Re: Tony]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Nope no files written at all unless your script writes them on purpose.
It all runs from the NETLOGON share.

Top
#186944 - 2008-04-16 01:37 AM Re: adding printers [Re: Tony]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
KiX32.EXE and WKiX32.EXE are stand alone scipt processors. There are no files that need to be installed anywhere. (Caveat - unless you are still using Win 95/98 machines).
_________________________
Today is the tomorrow you worried about yesterday.

Top
#186946 - 2008-04-16 02:30 AM Re: adding printers [Re: Gargoyle]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
For the record, some people prefer to copy the KiXtart executables to the local computers instead of having the executable run fron a NETLOGON share.
_________________________
There are two types of vessels, submarines and targets.

Top
#186948 - 2008-04-16 02:54 AM Re: adding printers [Re: Sealeopard]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Those on a 1MB or slower link maybe or those that WANT more management work, but in today's age where "most" are connected at 10,100,1000MB then it would be much easier to keep it all on the NETLOGON share.
Top
#186949 - 2008-04-16 05:10 AM Re: adding printers [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Regarding placement of the Kix executable..

We have over 300 branch locations, connected using Frame Relay at speeds between 128K and T1. None of the workstations (except for admin systems in the HQ location) has Kix installed locally.

We use my "Kix Universal Logon Script", which uses an INI file to define mappings. There are 18 possible drive mappings that get processed, with an average of 7 actual connected shares. Connections are based on group membership (or non-membership) and OU. One message file is displayed, and three external processes are called - two Kix and one EXE.

On the slowest link speed, all of this processes in 18 seconds or less if the config file is not cached on the local workstation, and under 12 seconds if the file is cached. This includes bringing down the Kix32 executeable (256K), the script (22K tokenized), and the config file (3K). I don't think this is unreasonable performance, although if I still had 33-56K dialup VPN users, I might put Kix32 locally on their laptops.

If you're wondering why I'd cache a 3K file and not the other 278K worth of files, I found that 20-24 reads of the INI file over the WAN link can add 60 seconds to the processing time - far less than copying it to the Temp folder and reading it locally.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#186950 - 2008-04-16 05:55 AM Re: adding printers [Re: Glenn Barnas]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, reading from a .INI file is costly, as the API reads the whole file first I believe. Thus, each access results in a complete file transfer to the client.

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

Top
#186990 - 2008-04-17 12:17 AM Re: adding printers [Re: Mart]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA

I have tried the code below and it doesn't work.

$users = "jdole","blee"

If ASCAN($users, @USERID)
$rc = AddPrinterConnection("\\ad2\hp4000")
EndIf

I thought I was running the old version Kixtart 2001 Release Canidate 3 (version 4) that caused it not to work, but have replaced it with the latest kix32.exe on the netlogon share.

I specify under the user account (under profile tab, logon script) --> kix32 login.kix

Btw, what is the WKIX32.EXE?

Any idea why it isn't working?

Tt

Top
#186996 - 2008-04-17 01:41 AM Re: adding printers [Re: Tony]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Try something like this.
You're not giving the correct information to ASCAN

Remove the semi-colon to allow the printer to install.

 Code:
If Not @LogonMode
  Break On
Else
  Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')


Dim $Users
$Users = Split("jdole:blee",":")

If ASCAN($users, @USERID)>=0
  ;$rc = AddPrinterConnection("\\ad2\hp4000")
  'Found User'
Else
  'Did not find User in array'
EndIf


Top
#186998 - 2008-04-17 02:10 AM Re: adding printers [Re: NTDOC]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA
I will try it tonigh once I get home. what is funny is that the code I posted early works sometimes???!!

What if I just want to list the user seperate.

For example.

If johnd, then add printer1, add printer2
and make printer2 the default

endif

If jwayne, then add printer3, add printer1, addprinter4
and make printers1 the default

end if

on and on

Thank in advance.

Tt

Top
#187003 - 2008-04-17 07:37 AM Re: adding printers [Re: Tony]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
If @UserID = XXX
addprinterconnection...
EndIf

Or

Select
Case @UserID = XXX
addprinter...
Case @UserID = YYY
addprinterconnection...
Case 1
;No match
Endselect
_________________________
Today is the tomorrow you worried about yesterday.

Top
#187009 - 2008-04-17 10:41 AM Re: adding printers [Re: Gargoyle]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA
Thanks for all your reply!!

I tested the following and it works.
-----------------------------------------
If @UserID = bob

AddPrinterConnection("\\lnx1\Brother_8860")
delPrinterConnection("\\lnx1\hp4000")
SetDefaultPrinter("\\lnx1\Brother_8860")

EndIf

If @UserID = jdole

delPrinterConnection("\\ps1\Brother_8860")
AddPrinterConnection("\\lnx1\hp4000")
AddPrinterConnection("\\lnx1\Brother_8860")
SetDefaultPrinter("\\lnx1\hp4000")

EndIf

*** I have a few questions ***.

1)

Select
Case @UserID = XXX
addprinter...
Case @UserID = YYY
addprinterconnection...
Case 1
;No match
Endselect

What does Case 1 mean at the 3rd line from the last line of the code above?

2) If I can recall in the past, if you specify the code below, you are just verifing if the printer connection exists (if not then add).

If AddPrinterConnection("\\lnx1\hp4000") = 0

3)On our indiviual user account, we currently specify a standard windows .bat file for mapping user's drive. For pushing out the printers, I plan to use kixtart and put it in the OU policy/user/logon. There shouldn't be any conflict with two different types of batch processing?

4) I have been out of the user side support for a while now. When you add printers via a script like kixtart vs adding the printers manually, do you lose the ability to see the printer's tray?

5) If deploying a script like kixtart, do i have to be concern about the drivers being loaded to the machine properly. All the workstation are windows xp pro. So far the user accounts I have tested didn't run into any problem without specifying the drivers. Seems like XP Pro reconized most of the printers we deploy. Both the old print server and new print server carry the same printers/drivers, but different share names.

6) For a large script like what we plan to use. Is there a code that we can specify if there is a problem the script skips to the next line of code?


TIA,
tt


Edited by Tony (2008-04-17 10:46 AM)

Top
#187010 - 2008-04-17 11:02 AM Re: adding printers [Re: Tony]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Quote:

....
What does Case 1 mean at the 3rd line from the last line of the code above?
....


Case 1 is always executed if none of the above cases are true.

 Quote:

....
2) If I can recall in the past, if you specify the code below, you are just verifying if the printer connection exists (if not then add).

If AddPrinterConnection("\\lnx1\hp4000") = 0
....


No. You are verifying that the printer is added without errors.

 Quote:

....
3)On our individual user account, we currently specify a standard windows .bat file for mapping user's drive. For pushing out the printers, I plan to use kixtart and put it in the OU policy/user/logon. There shouldn't be any conflict with two different types of batch processing?
....


There could be. It is best practice in my book to use on or the other. So a GPO based logon script or one specified in the user properties.

 Quote:

....
4) I have been out of the user side support for a while now. When you add printers via a script like kixtart vs adding the printers manually, do you lose the ability to see the printer's tray?
....


No.

 Quote:

....
5) If deploying a script like kixtart, do i have to be concern about the drivers being loaded to the machine properly. All the workstation are windows xp pro. So far the user accounts I have tested didn't run into any problem without specifying the drivers. Seems like XP Pro reconized most of the printers we deploy. Both the old print server and new print server carry the same printers/drivers, but different share names.
....


You need to be sure that the proper printer drives are loaded on your printer server.

 Quote:

....
6) For a large script like what we plan to use. Is there a code that we can specify if there is a problem the script skips to the next line of code?
....


You could use GoTo’s but they are considered bad practice and should not be used if even remotely possible because they make spaghetti code. Using some kind of error handler UDF (there are several in the UDF section) is the way to go.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187011 - 2008-04-17 12:07 PM Re: adding printers [Re: Mart]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
6) For a large script like what we plan to use. Is there a code that we can specify if there is a problem the script skips to the next line of code?


Do you mean like an "On Error Resume Next"?

KiXtart does not support "On Error" type statements, however the default action if you get an error is to continue processing - in other words, KiXtart will ignore the error and skip to the next line of code.

Top
#187012 - 2008-04-17 12:28 PM Re: adding printers [Re: Richard H.]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
One could do a simple error check like this.
Logging it to a log file, sending an e-mail or whatever action when an error occurs to report the error can also be used.

 Code:
$rc = Open(1, "c:\somefile.txt", 5)

If @ERROR
	?"There was an error opening the file."
	?"Error code: " @ERROR
	?"Error text: "  @SERROR
EndIf

;More code here.



Edited by Mart (2008-04-17 12:28 PM)
Edit Reason: Typo in the code.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187013 - 2008-04-17 01:53 PM Re: adding printers [Re: Tony]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
You might know this already, but...

The login script on my site supports Path Rewrite technology, which allows you to dynamically define a single resource connection. You can also set priorities so two resource records can compete for a single connection. This allows members of various groups to connect to resources in different sequences.

The ultimate configuration would be a full rewrite - the record references a lookup table in the config file. With this, a single record can lookup a resource (printer or disk) and map it based on the userid, OU, or group. Every user could effectively have a unique mapping, although it is more generally done by department (OU or Group).

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#187028 - 2008-04-17 06:03 PM Re: adding printers [Re: Glenn Barnas]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA


2) If I can recall in the past, if you specify the code below, you are just verifing if the printer connection exists (if not then add).

If AddPrinterConnection("\\lnx1\hp4000") = 0


So for the line of code, I am verifying if the printer is added successfully? Is this better practice than just puting only?

AddPrinterConnection("\\lnx1\hp4000")


Thanks for so much needed info.

Tt

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 978 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.052 seconds in which 0.021 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org