Wednesday, October 7, 2015

Epson Receipt Printers and RemoteApp

If you've ever had the joy of working with those two products I'm sure you shuddered as you read the title. I'm currently struggling my way through a RDS environment that has the requirement to be able to print to these receipt printers. The app is old and basically just throws a print job at the LPT1 port and hopes for the best so it doesn't work very well with redirected printers. Also I need to have it so the users don't need to do anything.

I know that RDP can redirect the local ports so I figured this would be easy, I was wrong. I couldn't get the LPT redirection working so I first came up with just adding the redirected printer to the app. Unfortunately it doesn't allow you to choose a printer when you print the first receipt it just throws the job at LPT 1. If you want to specify a printer you can do that in the options menu but the redirected printer name might change on every login because they append the session number to the end of the printer name. This would potentially require the user to change the printer settings every time they logged in. So that's "Plan B".

Next I thought I could use the old "net use LPT1 \\client\printer" to make it work. And indeed it did work but again there are problems. First, I'd have to make sure the local printer was shared. I don't like this idea because then people will be printing their receipts to each others receipt printers by accident. In order to have this run in a login script I'd have to make sure I checked for the local host name to map to the correct printer because they might be on a different machine. This is "Plan C".

I finally had a break through when I tried just doing a regular RDP session to the host server with the option to redirect ports checked but redirect printers unchecked. I figured out if I have a dummy printer on the server that is on the non-existent LPT1 port then it will print to the client because of the port redirection. Halleuja I think I'm onto something here. So why doesn't it work in remote app? I found the .RDP file in %appdata%\microsoft\workspaces\<guid>\resource and took a look a it. Port redirection is off! I knew that LPT redirection was allowed by default in GPO but I didn't realize that it was turned off by default in the RDP files.

Now to make that change in remoteapp. Well it turns out that 2008R2 had a GUI to do it but 2012 nixed that and the only option is powershell. That's not so hard except the remote desktop serivces blog entry had the command wrong. Boo.

The working command is:

Set-RDSessionCollectionConfiguration –CollectionName %collectionname% -CustomRdpProperty "redirectcomports:i:1"
Put your own collection name in for %collectionname%

Now this will add "redirectcomports:i:1" to the registry. You can check it at HKLM\Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\CentralPublishedResources\PublishedFarms\%collectionname%\DeploymentSettings

As far as I know to test it you'll have to remove the existing connection to this collection from your client machine, which deletes the RDP files, and then reconnect to download the new copies off the server.

So now I'm able to open the remoteapp app from the start menu on my client and print a receipt to the local receipt printer without having to make any changes in my app each time I log in. The only change I have to make is initially I have to tell it to use the local printer on the server. For ease I named both the server printer and the client local printer RECEIPT. Everything seems to be working so far. I've got two weeks left before it has to go into production.

No comments:

Post a Comment