Comment trouver des imprimantes inutilisées sous Windows (ou la dernière fois qu'une imprimante a été utilisée)?


2

Nous recherchons un moyen de rechercher les imprimantes inutilisées sous Windows (Windows 7 / Server 2008 et versions ultérieures).

Nous avons testé ce VBScript Comment: répertorier tous les pilotes d'imprimante non utilisés , et bien que sur le système soient des imprimantes inutilisées, aucun résultat n’a été obtenu.

'================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.0
'
' NAME: Unused_Printer_Drivers.vbs
'
' AUTHOR: Robert Murray
' DATE  : 20/10/2008
' SEE: http://robertomurray.co.uk/blog/2008/how-to-list-all-unused-printer-drivers-on-a-print-server-using-vbscript/
'
' COMMENT: Script to gather current attached printers, printer drivers
'           installed and list the unused drivers.
'
'========================================
On Error Resume Next


'def vars
Dim objDictionary, strComputer, counter, myfilename, forReading, forWriting, IEProg, total, _
    PrtDrvName, pos, thisComp

'computer on which to run check - "." is local machine
strComputer = "."

'Path and file in which to save report
myfilename = "tempprtDrvrs.html"

IEProg = "iexplore.exe"
counter = 0
forReading = 1: forWriting = 2: ynCreate = 1

'=========================================
'Set objects
'=========================================

'WMI connection
Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootCIMV2") 

'WMI queries
Set colPrinterItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_Printer")
Set colPrinterDrivers =  objWMIService.ExecQuery _
    ("Select * from Win32_PrinterDriver")

'to get computer name
Set objNetwork = CreateObject("WScript.Network")

thisComp = objNetwork.ComputerName

'scripting Dictionary -> database
Set objDictionary = CreateObject("Scripting.Dictionary")

'FSO & Shell
set fso = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("Wscript.Shell") 

'open file for writing
set myTextStream = fso.OpenTextFile(myfilename,forWriting,ynCreate)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'=================================================
'Do the hard work
'=================================================


'Add all printer drivers used by attached PRINTERS to database
    For Each objItem in colPrinterItems 

        objDictionary.Add objItem.DriverName, objItem.DriverName

        'not used.
        '"DriverName: " & objItem.DriverName
        '"Name: " & objItem.Name
        '" & objItem.PortName    
        'counter = counter + 1

    Next


    'write header & build table for report
    myTextStream.Write "<h1>Unused Printer Drivers</h1>"

    myTextStream.Write "<h5>Date: " & Now & "</h5>" & vbcrlf
    myTextStream.Write "<h5>Computer Name: " & thisComp & "</h5>" & vbcrlf

    myTextStream.Write "" & vbcrlf

    myTextStream.Write "" & vbcrlf

    myTextStream.Write "" & vbcrlf
    myTextStream.Write "" & vbcrlf
    myTextStream.Write "" & vbcrlf
    myTextStream.Write "" & vbcrlf

    myTextStream.Write "" & vbcrlf

    'reset counter - if used previously
    counter = 0


    'loop through all DRIVERS and if NOT in database then driver is NOT used so output this driver
    For Each objPrDrvrItem in colPrinterDrivers

        'get rid of the junk on the end of returned value
        pos=InStr(objPrDrvrItem.Name,",") -1
        PrtDrvName = Left(objPrDrvrItem.Name,pos)

        'check if in database
        if objDictionary.Exists(PrtDrvName) then

            ' Do nothing -> driver is in use.

        Else

            'Output printer driver name, platform and version of all not in use ie not in the database
            myTextStream.Write "" & vbcrlf
            myTextStream.Write "" & vbcrlf
            myTextStream.Write "" & vbcrlf
            myTextStream.Write "" & vbcrlf
            myTextStream.Write "" & vbcrlf
            myTextStream.Write "" & vbcrlf

            'increment counter
            counter = counter + 1

        end if


    Next

'write number of unused drivers on bottom row
myTextStream.Write "" & vbcrlf
myTextStream.Write "" & vbcrlf
myTextStream.Write "" & vbcrlf

'end table

myTextStream.Write "<table border=""1"" cellspacing=""2"" cellpadding=""3""><tbody><tr><th>Status</th><th>Driver Name</th><th>Platform</th><th>OS (3 is 2000 and above)</th></tr><tr><td>Driver not used.</td><td>" & PrtDrvName & "</td><td>" & objPrDrvrItem.SupportedPlatform & "</td><td>" & objPrDrvrItem.Version & "</td></tr><tr><td colspan="" 4""="">There are " & objDictionary.Count & " drivers USED and " & _
                            counter & " drivers UNUSED installed currently.</td></tr></tbody></table>" & vbcrlf


'close file
myTextStream.Close


'Finally - open file with IE
objShell.Run (IEProg & " " & myfilename)


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' END
'=====================================================

Nous avons un Windows 2008 R2 Terminalserver. le printer queues sont sur un second Windows 2008 R2 Server.

Existe-t-il un moyen d'obtenir l'heure à laquelle une imprimante a été utilisée la dernière fois?

En utilisant notre site, vous reconnaissez avoir lu et compris notre politique liée aux cookies et notre politique de confidentialité.
Licensed under cc by-sa 3.0 with attribution required.