Search This Blog

Dec 2, 2011

Printing from a Legacy Application - using 'Dir' with LPT port fails

Another cool case that show us how Microsoft Windows editions works with SMB protocol.
Let's think about the whole scenario:
    - When try redirect printing to any LPT port results in ‘Access Denied’ .
   
    - Using the command “net use lpt1 \\computername\printername” to redirect the output from an legacy application to a network printer. This command was working fine under Windows 2003 in order to enable network printing from the DOS application. After migrating the Print Server for Windows 2008 based the CMD (DIR >LPT1) and DOS Legacy Application it's not working.
    - Message "Access Denied" and "Printer not Available".
   
<Solution>
    - Download Processor Monitor and executed on Print Server.
    - Analyze the Logs and found the following information:
   
    C:\Windows\system32\ntvdm.exe
    Date & Time:    23/11/2011 15:12:23
    Event Class:    File System
    Operation:    CreateFile
    Result:    ACCESS DENIED
    Path:    \\;LanmanRedirector\;LPT1:00000000000fb07e\abcdserver\epson\
    TID:    6872
    Duration:    0.0057445
    Desired Access:    Generic Write, Read Attributes
    Disposition:    OpenIf
    Options:    Synchronous IO Non-Alert, Non-Directory File
    Attributes:    N
    ShareMode:    Write
    AllocationSize:    0
   
   
    - To resolve the issue we need to change the way the Servers and Workstations communication with each other.
    - Since the Windows Vista, Microsoft upgrade this way to communication using the SMB version 2.
   
    Server Message Blocks Protocol (SMB) is the file sharing protocol used by default on Windows-based computers. SMB 1.0 was designed for early Windows operating systems , but until Windows Server 2008 and Vista.
    SMB 2.0 was introduced in Windows Vista and Windows Server 2008. SMB 2.0 is designed for the needs of the next generation of file servers. Windows Server 2008 R2 and Windows Vista and Windows7 support both SMB 1.0 and SMB 2.0 in order to preserve backward compatibility.
   
    Here's how SMB is used when related to SMB versions:
        ○ When a Windows Server 2008/Vista "client" connects to a Windows Server 2008/Vista "server", SMB 2.0 is used.
        ○ When a Windows Server 2008/Vista "client" connects to a Windows 2000/XP/2003 "server", SMB 1.0 is used.
        ○ When a Windows 2000/XP/2003 "client" connects to a Windows Server 2008/Vista "server", SMB 1.0 is used.
        ○ When a Windows 2000/XP/2003 "client" connects to a Windows 2000/XP/2003 "server", SMB 1.0 is used.
   
   
    - OK. Now the solution:
    - Using the Regedit to disable SMB2 on the server (I used this one).
        1.Run "regedit" on Windows Server 2008 based computer.
        2.Expand and locate the sub tree as follows.
        HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters
       
        3.Add a new REG_DWORD key with the name of "Smb2" (without quotation mark)
        Value name: Smb2
        Value type: REG_DWORD
            0 = disabled
            1 = enabled
       
        4.Set the value to 0 to disable SMB 2.0, or set it to 1 to re-enable SMB 2.0.
       
        5.Reboot the server.
       
    - Restarted Services ["Server" "Printer Spooler" "Workstation"] . I prefer restart the server (but sometimes customer cannot).
    - Get a new ProcMon and no access denied or \\;LanmanRedirector logs found.
    - Tested DIR >LPT1 = OK
    - Tested on application and works.

4 comments:

  1. This same problem had bugged me for months now, and your suggestion has solved it! Thanks! To be honest, it never dawned on me that the SMB protocol version could have anything to do with printing problems, but alas, it did. Shame on Microsoft for silently disrupting a Windows feature that had worked flawlessly at least since the times of Windows NT 3.51!

    ReplyDelete
  2. Excellent and to the point writeup. Solved my issue. Thanks

    ReplyDelete
  3. I have been having problem with a 2008R2 based server printing to RDP client printers - legacy printing. Using your solution on the clients SOLVED the problem. THANK YOU.

    ReplyDelete
  4. I think this is the best solution
    Thanks
    Asis Panja
    panjaasis@google.com

    ReplyDelete