Date created: Sunday, January 20, 2013 3:16:09 PM. Last modified: Sunday, January 20, 2013 3:16:30 PM

Print Audit Wrapper

dim intDesiredYear, intDesiredMonth, intLastDay
dim strPath, strComputer, strCMD, strPrinterName, strLogFile

strPath = "C:\Scripts\PrintEventAudit.vbs"
intDesiredYear = Year(Now)
intDesiredMonth = Month(DateAdd("m", -1, Date))
'Prefix a zero if required
if(Len(intDesiredMonth)<2) Then
	intDesiredMonth = "0" & intDesiredMonth
End If
intLastDay = Day(DateAdd("d", -1, CDate((intDesiredMonth + 1) & "/01/" & intDesiredYear)))

'Clear up from last time
Set fso = Wscript.CreateObject("Scripting.FilesystemObject")
fso.DeleteFile "C:\Scripts\Printers\*",True

strComputer = "PrintSrv1"
strPrinterName = "Main Office - Black and White"
strLogFile = "C:\Scripts\Printers\H_MO_BW.txt"
getStats
strPrinterName = "Main Office - Colour Laser"
strLogFile = "C:\Scripts\Printers\H_MO_CL.txt"
getStats
strPrinterName = "Photocopier"
strLogFile = "C:\Scripts\Printers\H_PO.txt"
getStats

strComputer = "PrintSrv2"
strPrinterName = "Main Office - Black and White"
strLogFile = "C:\Scripts\Printers\H_MO_BW.txt"
getStats
strPrinterName = "Main Office - Colour Laser"
strLogFile = "C:\Scripts\Printers\H_MO_CL.txt"
getStats
strPrinterName = "Photocopier"
strLogFile = "C:\Scripts\Printers\H_PO.txt"
getStats


Sub getStats
strCMD = "cscript " & strPath & " " & strComputer & " " & chr(34) & strPrinterName & chr(34) & " * " & intDesiredMonth & "/01/" & intDesiredYear & "-" & intDesiredMonth & "/" & intLastDay & "/" & intDesiredYear & " " & strLogFile

Wscript.echo strCMD

set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.run strCMD
End Sub

Previous page: Print Audit
Next page: Update AD Details