Page 1 of 1 1
Topic Options
#13537 - 2001-10-25 07:04 PM assigning printers to roaming users
Anonymous
Unregistered


I need to write a script to assign users to a nearby printer. ( Win2000Server + Citrix meteframe XP )
The PC's are named thus: R09-038 for PC on connection 38 in room 9.
So, I understand I should start:

$room=substr(@wksta,2,2)

select
case($room="09")
; what do I put here to connect only to
; the room9 printer ?
endselect

I don't think anything should be stored on the client, so addprinterconnection wouldn't work... right ??

Also...
How is the Kix32 script called ? ...assuming it exists in the domain server winnt\sysvol\sysvol\<domain> directory.

Many thanks
Mark

Top
#13538 - 2001-10-25 07:14 PM Re: assigning printers to roaming users
Anonymous
Unregistered


Mark,

It really comes down to NAMING CONVENTIONS!

Do you have one for your printers?

What we do here is we have a small file that sit centrally named the same as the machine name.

When the user logs in it read the machine name and then reads the corresponding file which has already been defined to say what the nearest printers are to the workstation.

Yes you do use the ADDPRINTERCONNECTION to add the NETWORK printers to the workstations.

This gives you an added benefit that if someone want to change where they print to they don't have to change the login script just the file associated to the workstation.

Hope this is of assistance to you.

Top
#13539 - 2001-10-25 07:55 PM Re: assigning printers to roaming users
Anonymous
Unregistered


Thanks David

Yes, the printers are likewise named: R09_HP2200D - for example.

What I do need is for the printers in other rooms to be hidden.

Can you expand a bit on these files you mention ?

Regards
Mark

Top
#13540 - 2001-10-25 09:10 PM Re: assigning printers to roaming users
Anonymous
Unregistered


Here is the script we are using for printer mapping. In our installation, the last 4 characters are the cube number.

;************************************************************
;** Script: Map Printer Script
;** Created: 08/06/2001
;** Updated: 10/13/2001
;**
;** Author: David C. Miller
;** E-mail: david.c.miller@nextel.com
;**
;** Purpose / Comments:
;** Map printers based on account membership and cube location
;**
;** Variables:
;**
;** Macros called by this macro:
;** $StatusKix
;**
;** Updates
;** 08/31/2001 Created and added all North end Printers
;** 10/13/2001 Used registry to save printers and load from registry
;** 10/24/2001 Stopped using registry since it does not enhance
;** performance and ignores group changes
;**
;************************************************************

$Wk = @WKSTA
IF UCASE(VAL(SUBSTR($WK, Len($Wk), 1))) == UCASE(SUBSTR($WK, Len($Wk), 1))
$Cube = VAL(SUBSTR($Wk, Len($Wk) - 3, 4))
ELSE
$Cube = VAL(SUBSTR($Wk, Len($Wk) - 4, 4))
ENDIF
$Stat = "Setting printers for cube: " + $Cube CALL $StatusKix
$SysPrintKey = "HKEY_LOCAL_MACHINE\Software\BCC\Printers"
$X = DELTREE($SysPrintKey)
$UserPrintKey = "HKEY_CURRENT_USER\Printers\Connections"
$NumUserPrint = 0

;** Delete existing printer connections
DIM $Printer[30]
$Count = 0
GOSUB "DeletePrinters"
DIM $Printer[30]
$Count = 0
GOSUB "ConnectPrinters"
RETURN

:ConnectPrinters
SELECT
Case $Cube >= 1001 AND $Cube <= 1011
$Printer[$Count] = "\\BCCW2FS01\BCCHPTN1110"
$X = ADDPRINTERCONNECTION($Printer[$Count])
$Stat = "Added connection to printer: " + $Printer[$Count] CALL $Statuskix
$Count = $Count + 1
$Printer[$Count] = "\\BCCW2FS01\BCCLPTNSOUTH"
$X = ADDPRINTERCONNECTION($Printer[$Count])
$Stat = "Added connection to printer: " + $Printer[$Count] CALL $Statuskix
$Count = $Count + 1

Case $Cube >= 1012 AND $Cube <= 1022
$Printer[$Count] = "\\BCCW2FS01\BCCHPTN1100"
$X = ADDPRINTERCONNECTION($Printer[$Count])
$Stat = "Added connection to printer: " + $Printer[$Count] CALL $Statuskix
$Count = $Count + 1
$Printer[$Count] = "\\BCCW2FS01\BCCLPTNSOUTH"
$X = ADDPRINTERCONNECTION($Printer[$Count])
$Stat = "Added connection to printer: " + $Printer[$Count] CALL $Statuskix
$Count = $Count + 1
ENDSELECT
; If no printer selected above, go to default printer
If $Count = 0
$Printer[$Count] = "\\BCCW2FS01\BCCHPTN1427"
$X = ADDPRINTERCONNECTION($Printer[$Count])
$Stat = "Added connection to printer: " + $Printer[$Count] CALL $Statuskix
$Count = $Count + 1
$Printer[$Count] = "\\BCCW2FS01\BCCLPTNNorth"
$X = ADDPRINTERCONNECTION($Printer[$Count])
$Stat = "Added connection to printer: " + $Printer[$Count] CALL $Statuskix
$Count = $Count + 1
ENDIF
$X = SETDEFAULTPRINTER($Printer[0])
RETURN

;********************************************************
:DeletePrinters

$Name=EnumKey($UserPrintKey, $NumUserPrint)
IF @ERROR=0
$Loop = 1
DO
IF SUBSTR($Name, $Loop, 1) = ","
$Printer[$Count] = $Printer[$Count] + "\"
ELSE
$Printer[$Count] = $Printer[$Count] + SUBSTR($Name, $Loop, 1)
ENDIF
$Loop = $Loop + 1
UNTIL $Loop > Len($Name)
$NumUserPrint = $NumUserPrint + 1
GOTO DeletePrinters
ENDIF
IF $Count > 0
$Count = 0
DO
$X = DELPRINTERCONNECTION($Printer[$Count])
UNTIL $Printer[$Count] = "" OR $Count > 28
ENDIF
RETURN

[ 25 October 2001: Message edited by: David Miller, Nextel ]

Top
#13541 - 2001-10-25 09:27 PM Re: assigning printers to roaming users
Anonymous
Unregistered


Mark,

Our naming convention is like this:

Workstation:

XAABBCCC

Printer:

XXXXAABBCC


X= Device Type
A= Building No. (Across the nation)
B= Floor within the building
c= Sequential number of that device
1000 workstations/ 100 printers


So the file for workstation N0207016 (My Machine) looks like this.

code:

[Printers]
; Add the correct printers for the workstation here
Printer1_Install=Yes
Printer1_Path=\\MPRINT003\LW810020701
Printer1_Default=Yes

Printer2_Install=Yes
Printer2_Path=\\MPRINT004\HP4S020701
Printer2_Default=No

Printer3_Install=Yes
Printer3_Path=\\MPRINT004\HPCL020701
Printer3_Default=No

Printer4_Install=Yes
Printer4_Path=\\MPRINT001\LT616010103
Printer4_Default=No

Printer5_Install=Yes
Printer5_Path=\\MPRINT001\LT616010102
Printer5_Default=No

Printer6_Install=Yes
Printer6_Path=\\MPRINT001\LT616010101
Printer6_Default=No

Printer7_Install=Yes
Printer7_Path=\\MPRINT001\LT616010103
Printer7_Default=No


While the script looks like this:

code:

$Share = "\\Server\share$$"
$IniFile = $Share + "\" + @WKSTA + ".ini"
$num = 1
$PrinterNum = "Printer" + $num
$LPTNum = "LPT" + $num + ":"
$DoInstall = ReadProfileString($IniFile, "Printers", $PrinterNum + "_Install")
While $DoInstall <> ""
if $DoInstall = "Yes"
$Printer = ReadProfileString($IniFile, "Printers", $PrinterNum + "_Path")
? "Add $num $Printer"
$RetCode = AddPrinterConnection($Printer)
if $RetCode <> 0
? "Could not add printer $Printer"
else
$Default = ReadProfileString($IniFile, "Printers", $PrinterNum + "_Default")
if $Default = "Yes"
$RetCode = SetDefaultPrinter($Printer)
endif
USE $LPTNum $Printer
endif
endif
$num = $num + 1
$PrinterNum = "Printer" + $num
$LPTNum = "LPT" + $num + ":"
$DoInstall = ReadProfileString($IniFile, "Printers", $PrinterNum + "_Install")
Loop

Hope this makes my previous ramblings a little clearer.

Top
#13542 - 2001-10-25 11:26 PM Re: assigning printers to roaming users
Anonymous
Unregistered


Thanks very much guys for so much help. I'm going to have to peruse those details alongside the manual to see what I can make of them.

David Miller ...are you calling the registry on the domain controller there ?

David Gray ...so to clarify, these files, one for each client and a single script file, exist in the netlogon folder of my domain controller ?

Thanks again
Regards
Mark

Top
#13543 - 2002-08-09 09:57 AM Re: assigning printers to roaming users
Anonymous
Unregistered


Just checking back and I thought it'd be polite and helpful to post the solution I arrived at.

my script is as follows:

---------------------------

DelPrinterConnection ("\\MyServer\Room 19 Laser")
DelPrinterConnection ("\\MyServer\Room 9 Laser")
DelPrinterConnection ("\\MyServer\Room 9 Colour Printer")
DelPrinterConnection ("\\MyServer\Room 73 Laser")

$room=SubStr(%clientname%,2,2)

Select
Case ($room="19")
AddPrinterConnection ("\\MyServer\Room 19 Laser")
AddPrinterConnection ("\\MyServer\Room 9 Colour Printer")
SetDefaultPrinter ("\\MyServer\Room 19 Laser")
EndSelect

Select
Case ($room="09")
AddPrinterConnection ("\\MyServer\Room 9 Laser")
AddPrinterConnection ("\\MyServer\Room 9 Colour Printer")
SetDefaultPrinter ("\\MyServer\Room 9 Laser")
EndSelect

Select
Case ($room="73")
AddPrinterConnection ("\\MyServer\Room 73 Laser")
SetDefaultPrinter("\\MyServer\Room 73 Laser")
EndSelect

----------------------------

The file (printer.kix) is called from the user logon script with the line:

-----------------------------

\\MyServer\NETLOGON\Logon\kix32.exe \\MyServer\NETLOGON\Logon\printer.kix

-----------------------------

To admit my ignorance, my major problem was not knowing about the logon share. Once I had that figured, it was simply a case of adding a pause to the script, enabling scripts to be visible in ADU&C, and tweaking the script.

I'm aware this script could be tidied a lot, so i'm open to sugestions!

Thanks to the guys who volunteered the information I used to work out my own script.

(PS %clientname% is used instead of %workstation% to pick up the Citrix client name)

Mark [Wink]

[ 09. August 2002, 10:02: Message edited by: simps ]

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

Generated in 0.049 seconds in which 0.023 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