0 Replies Latest reply on Nov 24, 2016 10:39 PM by Justin Logan

    Print Task Issues

    Justin Logan

      For the last few years, some of our computers would not print when the Print Task was executed. The oddest part about it would be, after an update, some computers would be begin to be able to execute the Print Task and others would stop. After some serious digging this week, the root cause was found and solved! The printer selection is case sensitive; i.e. the printer defined in the Task did not match the exact uppercase and lowercase format of the printers installed on some of our computers. This explains why Task execution would stop working, or start working, after updates that affected installed printers - Windows seems to be somewhat inconsistent with naming Printers when they get added or updated.

       

      I updated the GetPrinter function in the Print Task script as follows:

       

      Function GetPrinter(paperSize)

       

      'Dims defined for case sensitive printer check

       

      Dim WshNetwork As Object

      Dim Printers As Object

      Dim printer As Variant

       

          If [__printer_prseltype] = 2 Then

              Select Case paperSize

                  Case 0

                      GetPrinter = "[__printer_papsize_A]"

                  Case 1

                      GetPrinter = "[__printer_papsize_A]"

                  Case 2

                      GetPrinter = "[__printer_papsize_B]"

                  Case 3

                      GetPrinter = "[__printer_papsize_C]"

                  Case 4

                      GetPrinter = "[__printer_papsize_D]"

                  Case 5

                      GetPrinter = "[__printer_papsize_E]"

                  Case 6

                      GetPrinter = "[__printer_papsize_A0]"

                  Case 7

                      GetPrinter = "[__printer_papsize_A1]"

                  Case 8

                      GetPrinter = "[__printer_papsize_A2]"

                  Case 9

                      GetPrinter = "[__printer_papsize_A3]"

                  Case 10

                      GetPrinter = "[__printer_papsize_A4]"

                  Case 11

                      GetPrinter = "[__printer_papsize_A4]"

                  Case 12

                      GetPrinter = "[__printer_papsize_DEF]"

              End Select

          Else

              GetPrinter = "[__printer_prname]"

          End If

       

      'Checking installed printers for match with PDM Task defined printer

       

      Set WshNetwork = CreateObject("WScript.Network")

      Set Printers = WshNetwork.EnumPrinterConnections

       

      For Each printer In Printers

          If UCase$(GetPrinter) = UCase$(printer) Then

              GetPrinter = printer

              Exit For

          End If

       

      Next

       

      End Function