#198094 - 2010-03-18 01:48 PM
Re: expertise sought for tweaking print mapping
[Re: BReed]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
Welcome to KORG!
You might want to look at the Kix login script on my web site, as it will do everything you're looking for with no additional coding. All resources are in an INI file for easy management.. you can use per-user INI files for extreme cases or testing (I have a personal INI where changes are made and tested before being placed in the common INI file). With just a few printer resource definitions and some lookup tables, you can map the desired printers from a list of hundreds. Mapping can be by user or computer goup, user or computer OU, subnet, AD Site, or user.
There are numerous options for setting printer defaults. We use a concept of "default eligibility" - you might define 5 resource records for printers, with the actual printers defined by a lookup by computer or user OU. One of those resources will be the default printer for all users unless it is overridden by another method. You can define a COMPUTER=PRINTER default relationship to set per-computer defaults, or even define a local environment variable to set a locally attached printer as the default.
Take a look at the Configuration Guide for information. The script is free to download and we provide both free and fee-based support.
FYI - it's in use at many sites around the world, including the US region of a large international travel company where printers are mapped at hundreds of retail locations and multiple corporate locations. Despite making hundreds of resource mapping decisions for drives, printers, messages, and secondary commands, our script completes in under 15 seconds even on the WAN links. (All DCs are at HQ, kix & script run from the central DC, so time includes loading kix and the script).
A couple of things about your code:- Kix is case-insensitive - the LCase functions are unnecessary and just add a layer of complexity.
- The IF LEN($USERGROUPS) > 0 statement can be replaced with IF $USERGROUPS - if the length is zero, it evaluates to false, if it contains any text, it evaluates to true. This results in a tiny performance gain, but when you do it many times, the results can be noticable.
- "?" is a shortcut for @CRLF, not a shortcut for a print statement like it is in BASIC. CRLF usually comes at the end of a line. For simple things, it won't matter, but as your scripts become more complex, starting each line with a CRLF will lead to formatting problems. Consider - CLS, then @CRLF "Hi!" - what line is the message on? Certainly NOT the first line!
- Consider using the EnumINI UDF to enumerate your INI file, or even one of the INI2Array UDFs. This could speed processing as well.
- Your call to UNMAPPRINTERS will work because Kix is forgiving. Calling a function should include the parens, as in UNMAPPRINTERS(). Other languages would likely throw an error without the parens. It also makes the code clearer to the reader.
- SubStr($string, 1, 10) is the same as Left($String, 10) and probably faster to execute.
- You get extra points for commenting your work!
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 566 anonymous users online.
|
|
|