Logo Background

USB printer from DOS

  • I have a Brother MFC215C printer connected through USB to my new Windows XP SP2 computer. When attempting to print from DOS programs (such as GWBASIC) nothing happens. I suspect DOS sends the print command to the LPT1 port as opposed to the USB port. So, how can I print to a USB printer from DOS?

    As you have discovered, DOS has no concept of USB printers because programs of this era were written long before USB was invented. When printing in DOS, the program will normally send the print job to the parallel port (LPT). So, we need a method to redirect the print jobs to the USB port so they can print on a USB printer. Fortunately, there is a method which can be used.

    The procedure involves sharing the printer, the same as sharing a printer over a network, and then locally connecting back to this ‘networked’ printer under the guise of the LPT1 port. Be aware, for this procedure to work correctly there must be nothing connected to the LPT1 port. Before beginning, make sure the USB printer works correctly through Windows. Once this has been verified, we need to share the printer. Go to the ‘Start’ menu > ‘Control Panel’ and open the ‘Printers and Faxes’ control panel (you may need to first click the ‘Printers and Other Hardware’ category). Right-click on the USB printer, and select ‘Sharing’¦’. If asked, click ‘If you understand the security risks but want to share printers without running the wizard, click here’ and then select ‘Just enable printer sharing’ and click OK. Enable ‘Share this printer’ and assign the printer a name. I recommend the name contains no spaces, and be short (to make life easier later on). A good name may be ‘brotherprinter’. Click OK to save and close the changes.

    Next, we need to determine the name of your computer and assign a better name if necessary. This is required because we will be mapping the LPT1 port to what is essentially a network printer share (even though it is local to the computer) so we need to know the name of the computer to connect to the printer share. Go to the ‘Start’ menu > ‘Control Panel’ and open the ‘System’ control panel (you may need to first select the ‘Performance and Maintenance’ category). In the window that appears, click the ‘Computer Name’ tab. Note down the ‘Full computer name’. If the name has spaces (e.g. ‘Franks Computer’) then you may wish to rename the computer, to a name without spaces, which will make the following procedure easier and a bit neater. To rename the computer, click the ‘Change’ button and type the new computer name (without spaces, e.g. ‘frankcomp’), and then press OK (you will then need to restart the computer to introduce the change.

    Now, we will map the USB printer to the LPT1 port. When a print job is sent to the LPT1 port, it will automatically be forwarded to the USB port (where the printer is located). So, for all intents and purposes, the DOS programs will think they are printing to the LPT1 port, so they will be happy. To setup this mapping, go to the ‘Start’ menu > ‘Run’ and type ‘cmd’ (without the quotes) then click OK. The command prompt window will appear. At the command prompt, type the following command:
    net use LPT1 computer_nameprinter_share /Persistent:Yes
    In the above command, replace with the name of the computer and with the name of the printer share. In the examples used above, the command would be the following:
    net use LPT1 frankcomprotherprinter /Persistent:Yes
    If the computer name or share does contain spaces and you cannot avoid this situation, enclosing the name or share in quotation marks should work, for example:
    net use LPT1 ‘Franks Computer’rotherprinter /Persistent:Yes

    What this command is doing is telling the operating system to map LPT1 to the printer share. It does not matter that your computer is not on a network, as the share is on the local computer (so the computer is just connecting back to itself). This is just a hack to get around the lack of USB support in DOS. The /Persistent:Yes switch tells the computer to re-establish this mapping each time the computer is rebooted. Be aware, it is very important the LPT1 port does not have anything connected, since this procedure will send all commands being sent to the LPT1 port to the USB printer.

    To verify the mapping has been correctly setup, type the command:
    net view computer_name
    It should display the share name of the printer, the type of share (Print), how the share is being used (used as: LPT1), and any comments.

    Open your DOS program and check whether you can successfully print to the USB printer by printing to the LPT1 port. If you have difficulties (or only garbage is printed) some users have reported you may need to change some printer settings. However, if you can print with no problems you probably can leave well enough alone and don’t need to change the settings. Also, be aware this will change the global settings for the printer, which will affect both printing through Windows and DOS. So, you will need to change the settings (as specified below) when you wish to print from DOS and will need to change them back to the original settings when printing through Windows. To change the settings so you can print through DOS, go to the ‘Start’ menu > ‘Control Panel’ and open the ‘Printers and Faxes control panel (you may need to first open the ‘Printers and Other Hardware’ category). Right-click on your printer and select ‘Properties’. In the window that appears, select the ‘Advanced’ tab and click the ‘Print Processor’ button. Note down the current ‘Default data type’ for each of the processors listed in the ‘Print processor’ list and then select ‘TEXT’ as the data type for each of the processors listed in the ‘Print processor’ list. Click OK and then OK again to save and close. Make sure you reset these to their original values when you are finished printing through DOS and wish to print through Windows.

    Now, open a DOS program and attempt to print to LPT1. Hopefully, the output should come through your USB printer. You should also be aware, because the /Persistent:Yes switch has been set, this mapping will be re-established each time the computer is restarted. Should you wish to remove the mapping at some stage in the future, use the command:
    net use LPT1 /delete

Leave a Comment
Hi there. If this is the first time you are posting a comment it will not appear immediately, but needs to be approved. This is necessary in order to combat comment spam. However, once you have submitted a comment (which is subsequently approved) you do not need to go through this process again - the site remembers who you are and auto-approves your comments. Nifty eh? Anyway, sorry about the inconvenience that this may cause for your first comment post.