Druckerwarteschlange auslesen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Druckerwarteschlange auslesen

    Hi,

    ich suche eine Möglichkeit oder evtl bereits fertiges Script, dass die Druckerwarteschlange von Windows! ausliest und per PHP oder ähnliches auf einer Website anzeigt.

    Es soll damit möglich sein, die Drucker abzufragen, um evtl einen geeigneten Drucker im Vorhinein auszuwählen.

    Leider hab ich bisher noch keine Möglichkeit gefunden, die Windows Druckerwarteschlange auszulesen ... bei Unix ist dies ja um einiges einfacher ...

    evtl kann mir da jemand behilflich sein ...

    Einen riesigen Dank im Vorraus für euer Bemühen und eure Hilfe ...

    Gruß
    Benni
    greywolve

  • #2
    Mit PHP selbst geht sowas natürlich nicht. Dazu braucht es externe Tools, die man dann via exec() aufruft, wie z.B. hier. Mehr durch Googeln.

    Kommentar


    • #3
      hi, danke für den tip ... muss ich mal schauen, ob die Funktionen der Tools für mich ausreichen ... der erste link aufjeden Fall nicht, da dieser nur die standard Programme von Windows öffnet

      Kommentar


      • #4
        Original geschrieben von greywolve
        hi, danke für den tip ... muss ich mal schauen, ob die Funktionen der Tools für mich ausreichen ... der erste link aufjeden Fall nicht, da dieser nur die standard Programme von Windows öffnet
        Ahh. Schade.
        Das hat mich gerade selbst interessiert, und ich bin auf das hier gestoßen. Das ist ziemlich cool, kannte ich noch nicht.
        Drucker auflisten geht damit definitiv, gerade selbst getestet:
        Code:
        wmic printer list status
        sieht mächtig aus, hat aber eine ziemlich komplexe Syntax.
        Und dann gibts noch das hier, das hilft vielleicht bei der zweiten Aufgabe weiter.

        Kommentar


        • #5
          Webinterface

          Einige Drucker bringen entsprechende Webinterface mit.
          Frag mal bei HP nach, Laserjet 1320 sollte sowas haben, aber ohne Gewähr...

          Kommentar


          • #6
            joa werd das alles nächste woche ma testen ... dann hab ich ma wieder bissi zeit ... mit den webinterfaces wirds leider nix, da wir mehrere drucker haben, die ich anzeigen lassen möchte ...

            aber nochmals danke für die antworten

            Kommentar


            • #7
              so hab das jetzt ma getestet ...

              hab mich für die wmi variante entschieden ... dazu hab ich 2 vbs scripte geschrieben (eins für den Drucker ... eins für die Warteschlange)

              Diese Scripte ruf ich dann per PHP,CGI,PERL auf ... egal kann man machen wie man will ... et voila alle Informationen die man benötigt werden ausgegeben ... DANKE AN DIE TIPS!!!


              Druckerinformationen ... printer.vbs
              Code:
               
              strComputer = "."
              Set objWMIService = GetObject( _
                  "winmgmts:" & "{impersonationLevel=impersonate}!\\" _
                  & strComputer & "\root\cimv2")
              Set colInstalledPrinters =  objWMIService.ExecQuery _
                  ("Select * from Win32_Printer")
              
              Wscript.Echo "<table width='80%' cellspacing=0 cellpadding=2 border=1 align=center rules=groups frame=box>"
              Wscript.Echo "<thead>"
              Wscript.Echo "<tr>"
              Wscript.Echo "<th bgcolor='#DDDDDD' colspan=4>"
              Wscript.Echo "<b>Printer Status Information</b>"
              Wscript.Echo "</th>"
              Wscript.Echo "</tr>"
              Wscript.Echo "</thead>"
              
              For Each objPrinter in colInstalledPrinters
              Wscript.Echo "<tbody>"
              Wscript.Echo "<tr bgcolor='#FFFFFF'>"
              
              Wscript.Echo "<td>"
              Wscript.Echo "Name: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "<b>"
              Wscript.Echo objPrinter.Name
              Wscript.Echo "</b>"
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "Location: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrinter.Location
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr bgcolor='#EEEEEE'>"
              
              Wscript.Echo "<td>"
              Select Case objPrinter.PrinterStatus
              Case 1
              strPrinterStatus = "Other"
              Case 2
              strPrinterStatus = "Unknown"
              Case 3
              strPrinterStatus = "Idle"
              Case 4
              strPrinterStatus = "Printing"
              Case 5
              strPrinterStatus = "Warmup"
              Case 6
              strPrinterStatus = "Stopped printing"
              Case 7
              strPrinterStatus = "Offline"
              End Select
              Wscript.Echo "Printer Status: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo strPrinterStatus
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Select Case objPrinter.ExtendedPrinterStatus
              Case 1
              strExtendedPrinterStatus = "Other"
              Case 2
              strExtendedPrinterStatus = "Unknown"
              Case 3
              strExtendedPrinterStatus = "Idle"
              Case 4
              strExtendedPrinterStatus = "Printing"
              Case 5
              strExtendedPrinterStatus = "Warmup"
              Case 6
              strExtendedPrinterStatus = "Stopped Printing"
              Case 7
              strExtendedPrinterStatus = "Offline"
              Case 8
              strExtendedPrinterStatus = "Paused"
              Case 9
              strExtendedPrinterStatus = "Error"
              Case 10
              strExtendedPrinterStatus = "Busy"
              Case 11
              strExtendedPrinterStatus = "Not Available"
              Case 12
              strExtendedPrinterStatus = "Waiting"
              Case 13
              strExtendedPrinterStatus = "Processing"
              Case 14
              strExtendedPrinterStatus = "Initialization"
              Case 15
              strExtendedPrinterStatus = "Power Save"
              Case 16
              strExtendedPrinterStatus = "Pending Deletion"
              Case 17
              strExtendedPrinterStatus = "I/O Activity"
              Case 18
              strExtendedPrinterStatus = "Manual Feed"
              End Select
              Wscript.Echo "Extended Printer Status: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo strExtendedPrinterStatus
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr bgcolor='#FFFFFF'>"
              
              Wscript.Echo "<td>"
              Select Case objPrinter.PrinterState
              Case 0
              strPrinterState = "Idle"
              Case 1
              strPrinterState = "Paused"
              Case 2
              strPrinterState = "Error"
              Case 3
              strPrinterState = "Pending Deletion"
              Case 4
              strPrinterState = "Paper Jam"
              Case 5
              strPrinterState = "Paper Out"
              Case 6
              strPrinterState = "Manual Feed"
              Case 7
              strPrinterState = "Paper Problem"
              Case 8
              strPrinterState = "Offline"
              Case 9
              strPrinterState = "I/O Activity"
              Case 10
              strPrinterState = "Busy"
              Case 11
              strPrinterState = "Printing"
              Case 12
              strPrinterState = "Output Bin Full"
              Case 13
              strPrinterState = "Not Available"
              Case 14
              strPrinterState = "Waiting"
              Case 15
              strPrinterState = "Processing"
              Case 16
              strPrinterState = "Initialization"
              Case 17
              strPrinterState = "Warming Up"
              Case 18
              strPrinterState = "Toner Low"
              Case 19
              strPrinterState = "No Toner"
              Case 20
              strPrinterState = "Page Punt"
              Case 21
              strPrinterState = "User Intervention Required"
              Case 22
              strPrinterState = "Out of Memory"
              Case 23
              strPrinterState = "Door Open"
              Case 24
              strPrinterState = "Server_unknown"
              Case 25
              strPrinterState = "Power Save"
              Case 1024
              strPrinterState = "Printing"
              End Select
              Wscript.Echo "Printer State: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo strPrinterState
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr bgcolor='#EEEEEE'>"
              
              Wscript.Echo "<td>"
              Select Case objPrinter.DetectedErrorState
              Case 0
              strDetectedErrorState = "Unknown"
              Case 1
              strDetectedErrorState = "Unknown"
              Case 2
              strDetectedErrorState = "Other"
              Case 3
              strDetectedErrorState = "No Error"
              Case 4
              strDetectedErrorState = "Low Paper"
              Case 5
              strDetectedErrorState = "No Paper"
              Case 6
              strDetectedErrorState = "Low Toner"
              Case 7
              strDetectedErrorState = "No Toner"
              Case 8
              strDetectedErrorState = "Door Open"
              Case 9
              strDetectedErrorState = "Jammed"
              Case 10
              strDetectedErrorState = "Offline"
              Case 11
              strDetectedErrorState = "Service Requested"
              Case 12
              strDetectedErrorState = "Output Bin Full"
              End Select
              Wscript.Echo "Error Status: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo strDetectedErrorState 
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Select Case objPrinter.ExtendedDetectedErrorState
              Case 0
              strExtendedDetectedErrorState = "Unknown"
              Case 1
              strExtendedDetectedErrorState = "Other"
              Case 2
              strExtendedDetectedErrorState = "No Error"
              Case 0
              strExtendedDetectedErrorState = "Low Paper"
              Case 0
              strExtendedDetectedErrorState = "No Paper"
              Case 0
              strExtendedDetectedErrorState = "Low Toner"
              Case 0
              strExtendedDetectedErrorState = "No Toner"
              Case 0
              strExtendedDetectedErrorState = "Door Open"
              Case 0
              strExtendedDetectedErrorState = "Jammed"
              Case 0
              strExtendedDetectedErrorState = "Service Requested"
              Case 0
              strExtendedDetectedErrorState = "Output Bin Full"
              Case 0
              strExtendedDetectedErrorState = "Paper Problem"
              Case 0
              strExtendedDetectedErrorState = "Cannot Print Page"
              Case 0
              strExtendedDetectedErrorState = "User Intervention Required"
              Case 0
              strExtendedDetectedErrorState = "Out of Memory"
              Case 0
              strExtendedDetectedErrorState = "Server unknown"
              End Select
              Wscript.Echo "Extended Error Status: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo strExtendedDetectedErrorState 
              Wscript.Echo "</td>"
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr>"
              Wscript.Echo "<td colspan=4 bgcolor='#DDDDDD'>"
              Wscript.Echo "&nbsp;"
              Wscript.Echo "</td>"
              Wscript.Echo "</tr>"
              Wscript.Echo "</tbody>"
              
              Next
              Wscript.Echo "</table>"
              Warteschlange ... queue.vbs:
              Code:
              strComputer = "."
              Set objWMIService = GetObject( _
                  "winmgmts:" & "{impersonationLevel=impersonate}!\\" _
                  & strComputer & "\root\cimv2")
              Set colCurrentPrintJobs =  objWMIService.ExecQuery _
                  ("Select * from Win32_PrintJob")
              
              Dim total,jahr,tag,monat,datum,stunde,minute,sekunde,zeit
              
              Wscript.Echo "<table width='80%' cellspacing=0 cellpadding=2 border=1 align=center rules=groups frame=box>"
              Wscript.Echo "<thead>"
              Wscript.Echo "<tr>"
              Wscript.Echo "<th bgcolor='#DDDDDD' colspan=4>"
              Wscript.Echo "<b>Current PrintJobs on Printserver</b>"
              Wscript.Echo "</th>"
              Wscript.Echo "</tr>"
              Wscript.Echo "</thead>"
              
              For Each objPrintJob in colCurrentPrintJobs
              Wscript.Echo "<tbody>"
              Wscript.Echo "<tr bgcolor='#FFFFFF'>"
              
              Wscript.Echo "<td>"
              Wscript.Echo "Caption: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "<b>"
              Wscript.Echo objPrintJob.Caption
              Wscript.Echo "</b>"
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "Status: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrintJob.Status
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr bgcolor='#EEEEEE'>"
              
              Wscript.Echo "<td>"
              Wscript.Echo "Document: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrintJob.Document
              Wscript.Echo "</td>"
              
              dim sizemb
              sizemb = objPrintJob.Size / 1048576
              
              Wscript.Echo "<td>"
              Wscript.Echo "Size: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo Round(sizemb,2) & " MB"
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr bgcolor='#FFFFFF'>"
              
              Wscript.Echo "<td>"
              Wscript.Echo "Owner: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrintJob.Owner
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "Host: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrintJob.HostPrintQueue
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr bgcolor='#EEEEEE'>"
              
              Wscript.Echo "<td>"
              Wscript.Echo "Job Status: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrintJob.JobStatus
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "Total Pages: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrintJob.TotalPages
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              Wscript.Echo "<tr bgcolor='#FFFFFF'>"
              
              datum = Left(objPrintJob.TimeSubmitted,8)
              zeit = Mid(objPrintJob.TimeSubmitted,9,6)
              jahr = Left(datum,4)
              monat = Mid(datum,5,2)
              tag = Right(datum,2)
              stunde = Left(zeit,2)
              minute = Mid(zeit,3,2)
              sekunde = Right(zeit,2)
              
              Wscript.Echo "<td>"
              Wscript.Echo "Time Submitted: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "<b>"
              Wscript.Echo tag & "." & monat & "." & jahr & " - " & stunde & ":" & minute & ":" & sekunde & " Uhr"
              Wscript.Echo "</b>"
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo "Pages printed: "
              Wscript.Echo "</td>"
              Wscript.Echo "<td>"
              Wscript.Echo objPrintJob.PagesPrinted
              Wscript.Echo "</td>"
              
              Wscript.Echo "</tr>"
              
              Wscript.Echo "<tr>"
              Wscript.Echo "<td colspan=4 bgcolor='#DDDDDD'>"
              Wscript.Echo "&nbsp;"
              Wscript.Echo "</td>"
              Wscript.Echo "</tr>"
              Wscript.Echo "</tbody>"
              
              Next
              Wscript.Echo "</table>"

              Kommentar


              • #8
                und als letztes noch (bei mir) das Perl Script:
                Code:
                #!c:/perl/bin/Perl.exe -w
                ##
                ##  message - perl script to process the action GET variables
                ##
                
                use warnings;
                use CGI::Carp qw(fatalsToBrowser);
                
                
                print "Content-type: text/html\n\n";
                print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', "\n";
                print "<html><head><title>Printer Status Information</title></head><body>\n";
                
                ## back button and status information
                print '<body>';
                print '<a href="http://wo auch immer hin">Zur&#252;ck</a>';
                print '</body>';
                print '<br>';
                
                ## execute the script
                print '<br>';
                print `queue.vbs`;
                print '<br>';
                print '<hr>';
                print '<br>';
                print `print.vbs`;
                
                
                print "</body></html>";

                Kommentar

                Lädt...
                X