Link to home
Start Free TrialLog in
Avatar of stumurray
stumurray

asked on

Thin Client with Terminal Services Printing

We have some HP T5145 thin clients which we use as point of sale systems.  Each one has an Eposn receipt printer connected to the parallel port.  When we connect the session to the Terminal Server, the printer is mapped and we can print to it from Windows.  The problem is that our POS system needs the printer to be mapped to an LPT port.

I can manually create a new printer, and manually select the TS003: PRN1 (or whatever) port that the client has connected on, share the printer and the use "net use" to map the correct LPT port but I need to be able to script this.

Probable steps:

1.  Find current TS session number
2.  Create new printer using this session number and share
3.  Net use ... etc
Avatar of Bryon H
Bryon H
Flag of United States of America image

can the terminal server address the local workstation that has the printer, by netbios name?
if so, just share the printer as like for example "epson"
then on the server, net use lpt1: \\workstation\epson /persistent:yes

if not........  you're better off getting this epson onto a jetdirect, ethernet, with an ip address... and carve port tcp 9100 over in the firewal to nat over to the jetdirect....  then set up a new printer on the server, pointing to the ip address.... share it from the server, then
net use lpt1: \\server\sharename /persistent:yes

the old pos app won't even know what happened, but it'll work
ASKER CERTIFIED SOLUTION
Avatar of Cláudio Rodrigues
Cláudio Rodrigues
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stumurray
stumurray

ASKER

tsmvp,

Your script is exactly what I am looking for, however when I run it, I get an error saying "You do not have permission to modify settings for this printer".  Apparently redirected printer naming has been disabled in 2008......but I am unsure as to why we are renaming anything and not just creating a new printer...?

Thanks, nearly there!

Stuart
Am thinking that there is an issue with this script and the syntax change in 2008 - redirected printers show as PrinterName (redirected 5), the number being the session number...
Well in that case you may need to adjust the script based on the redirected name created on Server 2008.
Also the permissions issue may not be easy to fix. Have you looked at a tool called RenPrinters?
http://www.babbage-tech.com/products/renprinters/

Cláudio Rodrigues
Citrix CTP
But why are we renaming the printer?  I don't want to touch the existing one - I just want to create a new printer that uses the same port as the existing one.
In this case, modify the script to match the new naming convention. If you know scripting this should be VERY easy.
Next step, and you can try that as a user without even running the script, is to share the printer created by the TS for the user, using the 'rundll32 printui.dll,PrintUIEntry /Xs /n $TSPrinterName sharename $Sharename attributes +Shared'  where $TSPrinterName is the new naming convention that you can get off the registry key I read on the script.

Cláudio Rodrigues
Citrix CTP
 
This is the problem - you cannot share a redirected printer.  I need to create a new printer on the same port and then share that one.
Well if gets down to creating a new printer, you can script that I am certain.
http://support.microsoft.com/kb/189105

So the port you can use my script to find it (as it gets to the registry). Then create a new printer connected to the same port, share it and map it.
Would not that work?

Cláudio Rodrigues
Citrix CTP
Yes that will work - looks like I can create the printer using the printUI.dll: http://go.microsoft.com/fwlink/?LinkId=41178 

Now to combine your KIX script with the VB...
OK, have managed it:

;Delete existing printer
Shell 'rundll32 printui.dll,PrintUIEntry /dl /n "Generic / Text Only"'

;Read the default printer from the registry.
$DefaultPrinter = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device")

;Example: CutePDF Writer (redirected 51),winspool,TS064

;Extract Port Name
$PortName = Right("$DefaultPrinter","5")
 
;Create new printer on existing port number
Shell 'rundll32 printui.dll PrintUIEntry /if /f %windir%\inf\ntprint.inf /r "$PortName" /m "Generic / Text Only" /u'
;Share the printer
Shell 'rundll32 printui.dll,PrintUIEntry /Xs /n "Generic / Text Only" sharename "Receipt" attributes +Shared'

USE LPT2: /DELETE
USE LPT2: \\127.0.0.1\Receipt

Thanks Claudio - it was your script to get the data from the registry that I was missing.
Had to modify for Server 2008.  Provided script was to rename an existing printer which wasn't quite the requirement.