Dynamic LPT mapping
Jul 29, 2022 15:13:46 GMT 1
Post by jcat on Jul 29, 2022 15:13:46 GMT 1
Scenario: We have several custom DOS applications (written in Clipper) that are programmed to print to LPT1 and LPT2 through the normal user workflows. A DOS-based menu application is used to present the different applications to the user and when an application is chosen it executes a batch script to dynamically map the LPT ports to printers in the Windows domain (using NET USE). This worked very smoothly under NTVDM though I don't know how this ever worked in the days before Windows but they were using Netware at that time so maybe it had some sort of server-side support for redirecting the print output.
My attempt to reproduce this setup with vDos has fallen short because config.txt statically maps the ports. I thought I could work around this with
LPT1 = "LPT1":
LPT2 = "LPT2":
and then I have vDos execute a batch script in the Windows environment (using CMD "program" HIDE) to execute the NET USE commands. In theory this should work. But the problem is that vDos keeps throwing "https://vdos.proboards.com/post/1442 (2)". In a prior post it was said that you shouldn't try to bind the ports this way, but it didn't explain the reason (vDos will claim the device exclusively, but why is that a problem if nothing else is using the port?).
It's also not obvious why this binding fails. On the assumption that the problem is that the port isn't bound to anything when starting vDos, I created a Dummy printer (in Windows) assigned to LPT1 and I get the same error. If I delete the printer and I run NET USE LPT1 /DELETE, I still get the error.
Assuming this approach of dynamic printer switching is not technically possible, do you have any recommendation for how to handle this gracefully? The only solution I can think of is to eliminate the menu application and replace it with multiple vDOS configs (one per program with statically mapped printers) and a shortcut icon to the correct vDos launcher. I'd rather not ask the users to pick the printer from the Windows pop-up because that will be error prone (printing the form to the wrong printer) and it's not something they've ever needed to worry about.