How to access parallel ports created by NET command in Windows XP?

5

1

I am trying to get a USB-to-Parallel IEEE-1284 cable which is showed as USB Printing Support in Device manager to work as a LPT port and tried the answer here. Using this command:

NET USE LPT1: \\[Computer-Name]\Printer /PERSISTENT:YES

The command execute successfully but I can't see the LPT1 in Hardware Devices to get the address to write to it. I know the port I create exits because I made a Java application that lists Serial and Parallel ports using RXTX lib, here is the output:

enter image description here

I added all that LPT ports with the NET command because my PC doesn't have any. But I don't see them anywhere to get the address and RXTX lib doesn't allow me to get port address AFAIK. Any ideas how to access ports?

EDIT:

Ok, to clarify things a little, I have a USB-to-Parallel IEEE-1284, when you connect it to a Windows XP machine it is showed as an USB Printing Support device so It doesn't appear as a LPT port because it is designed to work with printers.

I created a Printer with Generic/Text driver and connected it to USB001 port because it is the port of the USB cable. Then I share the printer and create a LPT port using NET command. Now I want to write data to that LPT port as I would do with any other native LPT port using for example InpOut32.dll.

If it is not possible to access the port on that way, how can I get access to the port to write/read raw data to it? Not to print a document but to write/read raw data to it as you would do with any parallel port.

Andres

Posted 2013-09-18T01:10:34.340

Reputation: 81

Can't you do something like public static final String PARALLEL_PORT = "LPT1"; as shown in the Parallel Communications example code?

– martineau – 2013-09-18T04:19:47.993

Historically, LPT1's hardware port address is 0x3BC (see Interfaces).

– martineau – 2013-09-18T04:25:36.460

No, I have to use it in another program and I need the port address. Yes, but the address is not the same for every port isn't it? – Andres – 2013-09-18T10:06:08.100

LPT2 and 3 have different fixed addresses (0x378 and 0x278 respectively). These three addresses are the same on all IBM PC-compatible systems.

– martineau – 2013-09-18T12:42:10.050

This doesn't seems to work with Parallel Ports created with this method – Andres – 2013-09-25T19:04:33.067

If you are looking for a port address such as 0x378, I don't believe that a "net use lpt?" device has one, nor that it is listed anywhere in Device Manager. – harrymc – 2013-09-26T08:13:14.733

So what kind of an address are you looking for, besides its name of "LPT1"? – harrymc – 2013-09-27T05:57:24.487

I need a way to access the ports, I mean, how can I use them? I can't write a program and ask him to access LPT2 I need the address. – Andres – 2013-09-27T14:58:54.200

Maybe we are all missing the point here (or at least i am). Do you have a "Parallel-to-USB IEEE-1284 cable" as in your question or a "USB-to-Parallel IEEE-1284 cable" as in one of your comments? Maybe you can clarify in your question exactly what printer and connection to your computer you have, and what kind of software (DOS or Windows) is trying to access the printer (and maybe why it needs a port-number). – Rik – 2013-09-27T17:49:07.477

See my edited question, hope is clearer now. – Andres – 2013-09-28T01:37:58.783

Answers

1

Ok. So you connected a parallel device/printer via a "USB-to-Parallel IEEE-1284"-cable to the USB-port of your computer. Now you need to directly communicate to it. I understand you can't change the software directly to communicate with modern ports like USB001 etc. like the drivers of scanners do. And the software you have needs to communicate by normal protocol for old-LPTx ports (i.e. 0x378 instead of LPT1 etc.)

That leaves you with one option and that is "emulation". This should be done by the driver which came with the "USB-to-Parallel IEEE-1284"-cable. This driver should make a LPTx port and capture port-communication etc. But most (if not all) of these adapters come with drivers who emulate an USB-printer. In most cases this is the easiest (and even in case of old DOS-programs this can be solved with a NET command) but when it comes to real port-communication it is useless.

So you need to find a program that can emulate a LPTx (and its ports) and bidirectionally communicate with (any) USB-driver on your computer. I have not found one (yet).

The only thing useful i found was this Converter From USB To Parallel. This one emulates the LPTx and ports and communicates directly with the adapter. I have not tested this myself but the info-page looks promising. From the help-file:

The USB2LPT device and its driver enables redirecting of port access by random application software to a USB-attached parallel port, i.e. emulating a parallel port via USB. This unique solution works on all USB supporting Windows operating systems.

It does label its own driver as "Driver unstable" but you'll get the idea for what you're looking for. It also needs a special USB2LPT-adapter though. From its faq-page:

Q3. Can I use the USB2LPT.SYS driver with a regular (cheap) USB to parallel printer adapter?
A. Of course not! It's never possible due to design limitations of such adapters. See below.

It also lists as a minus for itself its Reduced speed due to emulation (expect 10..100 times slower). But it will allow communication with Base address same as built-in (378h, 278h). If you like you can make your own adapter. The schematics are all on the site. Here you can find complete instructions (including videos) on how to build one. Or else you can mail him for details on how to get one.

USB2LPT-adapter USB2LPT-adapter Converter From USB To Parallel

Rik

Posted 2013-09-18T01:10:34.340

Reputation: 11 800

Yes, I read about it a few weeks ago but I have to buy their cable and I am trying to get to work my cable first. Thank you! – Andres – 2013-09-30T15:35:37.260

I thought perhaps you were capable of building your own :) (instructions are included). But you're right. This software won't work without that adapter. A pure software solution would be best but hard to find. On here there was a suggestion to modify the source code to interact with any hardware/adapter but i haven't found anyone who has done this.

– Rik – 2013-09-30T16:00:16.083

Maybe this article is of interest. It only shows writing to a usb-lpt adapter but it should work with the normal ones. It's pretty 'do it youself' but it shows it's no easy task to write (i.e. toggle a bit) (not to mention read) the usb-lpt adapter which is meant for normal printers (and not other communication devices).

– Rik – 2013-09-30T22:51:04.797

And finally a note on USB parallel port adapters.

– Rik – 2013-09-30T23:05:54.240

1

I think that you may be going about this all wrong. You should not be using "NET USE" but rather using the adapter's software driver to associate a virtual printer port with the USB port. Rik has posted a screenshot of how this works. Only if the adapter's software allows it, should you then be able to write as if that physical port existed.

The NET USE LPT1 command that you showed is for when you connect to a printer on your own or another computer, and set that printer as your local (LPT1) printer. It is based on printing to the device name LPT1 and then redirecting that, which you have said your software won't do (requiring a hardware port).

Here is a driver from Startech, that makes some of these cables, but I don't know if it will work for you; it does work with some other models (including ones that I've owned): http://sgcdn.startech.com/005329/media/sets/ASIX_MosChip-MCS7715_Drivers/ASIX_MCS7715.zip

In the meanwhile, get rid of that NET USE command; it's really not helping you right now, and if you could get it to work at all with the local printer, would still require you to be writing to the LPT1 device (not to the hardware location where it would be, if only it existed.)

Debra

Posted 2013-09-18T01:10:34.340

Reputation: 4 000

I unninstalled the driver Windows XP was installing for the cable and installed this one but didn't work. No I can't even manage to make Windows to install a driver for the cable. – Andres – 2013-09-30T15:34:34.723

0

You will need the .NET-Framework and PowerShell, but with this script, you can get access to a list of any Parallel-Ports installed on your system.(+Additional informations)

$strComputer = "." 

$colItems = get-wmiobject -class "Win32_ParallelPort" -namespace "root\CIMV2" ` 
-computername $strComputer 

foreach ($objItem in $colItems) { 
      write-host "Availability: " $objItem.Availability 
      write-host "Capabilities: " $objItem.Capabilities 
      write-host "Capability Descriptions: " $objItem.CapabilityDescriptions 
      write-host "Caption: " $objItem.Caption 
      write-host "Configuration Manager Error Code: " $objItem.ConfigManagerErrorCode 
      write-host "Configuration Manager User Configuration: " $objItem.ConfigManagerUserConfig 
      write-host "Creation Class Name: " $objItem.CreationClassName 
      write-host "Description: " $objItem.Description 
      write-host "Device ID: " $objItem.DeviceID 
      write-host "DMA Support: " $objItem.DMASupport 
      write-host "Error Cleared: " $objItem.ErrorCleared 
      write-host "Error Description: " $objItem.ErrorDescription 
      write-host "Installation Date: " $objItem.InstallDate 
      write-host "Last Error Code: " $objItem.LastErrorCode 
      write-host "Maximum Number Controlled: " $objItem.MaxNumberControlled 
      write-host "Name: " $objItem.Name 
      write-host "Operating System Auto-Discovered: " $objItem.OSAutoDiscovered 
      write-host "PNP DeviceID: " $objItem.PNPDeviceID 
      write-host "Powe rManagement Capabilities: " $objItem.PowerManagementCapabilities 
      write-host "Power Management Supported: " $objItem.PowerManagementSupported 
      write-host "ProtocolS upported: " $objItem.ProtocolSupported 
      write-host "Status: " $objItem.Status 
      write-host "Status Information: " $objItem.StatusInfo 
      write-host "System Creation Class Name: " $objItem.SystemCreationClassName 
      write-host "System Name: " $objItem.SystemName 
      write-host "Time Of Last Reset: " $objItem.TimeOfLastReset 
      write-host 
} 

Source:Technet-Microsoft

Christian

Posted 2013-09-18T01:10:34.340

Reputation: 6 571

I founded it searching over internet but I don't know how to execute Power-Shell scripts and Power-Shell seems to be a paid software – Andres – 2013-09-25T19:36:53.777

@Andres It is a freeware. But your Windows version has to be a valid one. So no cracked or something. Because during the installation, it will check, if there is a original windows xp-version. Download

– Christian – 2013-09-25T19:40:03.053

I tested the script and it doesn't works on PowerShell v2.0 – Andres – 2013-09-25T20:12:24.787

Ok got it working but it doesn't give me the parallel ports created with NET – Andres – 2013-09-25T21:25:01.767

The parallel port is not created with the NET USE command. The command only tells the system that any output that was aimed at LPT1 should instead be sent to the printer at \computername\printername. – Debra – 2013-09-28T19:27:20.543

0

(I have rewritten my previous answer which didn't fit your case.)

The cable is apparently recognized by Windows, but the driver should have done some more extensive emulation for it to be directly available for writing.

This forces you to invent your own device, in this case a generic printer. It's entirely possible that this printer is unusable because it sends control-codes over the cable to which whatever device is connected on the other side doesn't know how to respond. A printer cable might in this case not be the best means of connecting devices.

The best I can find is in the article Getting a handle on usbprint.sys where a C program was developed for directly writing data to a printer by bypassing the print driver. You could possibly use this simple program as a template to develop your own program for writing the data to the cable.

For the program to work, one must find the GUID of the interface in Windows of the cable, assuming that the cable does have an accessible interface GUID. You will need to search the registry using regedit or the faster RegScanner.

harrymc

Posted 2013-09-18T01:10:34.340

Reputation: 306 093

Yes, on this way I create LPT1 and create a printer which prints on LPT1 port, but how I can assign this port to the USB-to-Parallel IEEE-1284 cable? Otherwise the printer is printing to the LPT1 virtual port. – Andres – 2013-09-27T17:18:39.163

You say above that the NET USE LPT1: command has successfully connected LPT1 to the cable. If this is not the case, do you have in the "Add printer" dialog an available port named USB001 or similar. – harrymc – 2013-09-27T17:26:34.693

Yes I created a printer which is connected to USB001 which is my cable, but I can't access to the LPT port. See my edited question please. – Andres – 2013-09-28T01:38:57.287

You don't need the LPT, so better delete it. What you need is a local printer created with the driver of the real physical printer and using the USB port of the cable. Unplug all unnecessary USB devices while creating the printer. The port number is likely to be USB001, that I hope you will see in the ports list, which is the default virtual printer port in Windows for USB printers. USB002 only appears if USB001 is already in use. – harrymc – 2013-09-28T06:04:56.033

In addition to the above : What make is your USB-to-Parallel cable and did you receive a drivers disc when you bought it? – harrymc – 2013-09-28T10:53:16.713

See my edited question. I don't need to print a document, I need to use this USB-to-Parallel to write/read raw data on it. The cable is Z-TEK (http://www.z-tek.com.cn/) very Chinese cable and I didn't receive any CD with drivers

– Andres – 2013-09-28T16:43:28.930

I still think you are missing a driver. I can't manage to get on z-tek.com.cn, but I hope you have searched there for a driver. The only one I found is here and will only work on XP 32-bit. It comes up as clean in VirusTotal, but take precautions including a system restore point.

– harrymc – 2013-09-28T17:48:56.527

I installed it, is a driver updater software nothing more and no newer drivers were found. The cable is recognized as USB Printing Support so I don't think the driver is the problem. – Andres – 2013-09-28T18:56:05.597

I have rewritten my answer, but I cannot guarantee that the outlined approach will work. You might be better off getting another kind of connecting cable. – harrymc – 2013-09-29T12:10:43.870