Ми шукаємо спосіб знайти невикористані принтери у Windows (Windows 7 / Server 2008 та новіших версій).
Ми перевірили цей VBScript Як робити : Список усіх невикористаних драйверів принтерів , і хоча в системі є невикористані принтери, результатів не було.
'================================
'
' 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
'=====================================================
У нас є Windows 2008 R2 Terminalserver
. printer queues
Знаходяться на second Windows 2008 R2 Server
.
Чи є спосіб отримати час, коли останній раз принтер використовувався?