If you move an older application to Windows 7 and you have mapped LPTn to a network printer using "NET USE", and you have ASSIGN TO “LPT1:” (or LPT2: etc) in the SELECT clause of the COBOL program, you may receive run time (RTS) error 9/013 when attempting to access the printer. Yet, if from the command line you physically copy a file to the LPTn port specified in the NET USE statement, it prints.
Assume the following SELECT statement in the COBOL program:
SELECT PRINT-FILE ASSIGN TO "LPT1:"
FILE STATUS IS FILE-STAT.
And assume the following dos command is set to specify the network printer (possibly in a batch (.bat) file:
NET USE LPT1: \\\\machine-name\\HPLaserJet /persistent:yes
where machine name is the print server with the printer drivers installed, and 'HPLaserJet' is the ‘Share name’ on the ‘Sharing’ tab in the ‘Printer Properties’ of the printer selected from the ‘Devices and Printers’ in Windows 7 on that printer server.
If you're using any version of Net Express 5.1 prior to WrapPack6 or Studio EE 6.0 prior to SP2 you will receive RTS error 9/013 (file not found) when trying to print from the COBOL program running on Windows 7 or Vista.
However, if you were to directly copy a file (eg copy abc.txt LPT1) it would print on the printer specified by the NET USE statement.
The problem was caused by a change within the operating system that was not reflected in the COBOL RTS.
This has been fixed in Net Express 5.1 WS6 and Studio 6.0 EE SP2.
However, it is strongly advised that this method of printer selection be changed and printing be managed via the PC_PRINTER routines to directly access Windows printing.
A couple of points:
If you only have 1 printer (i.e. you always ASSIGN TO “LPT1:”) then you should consider using the printer_redirection runtime tunable.
Also, the NET USE statement on Windows 7 should be set using Administrator permissions. For example, put the NET USE statement in a batch (.bat) file and when you click on it select ‘Run as Administrator’.