Part 2.
My goal is to basically take this script, have it monitor the print queu for a specific printer, and if the queu ever has >0 jobs, to play a .wav file.
Gar, didn’t I just get done doing this for eight hours today.
Option Explicit
Dim strComputer, strTargetPrinter, strWaveFile
Dim objWMIService, objPrintQueue, colPrintQueues, objShell
strComputer = "."
strTargetPrinter = "hp deskjet 3820 series"
strWaveFile = "c:\windows\media\ding.wav"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPrintQueues = objWMIService.ExecQuery _
("Select * from Win32_PerfFormattedData_Spooler_PrintQueue Where Name = '" & strTargetPrinter & "'")
For Each objPrintQueue in colPrintQueues
If objPrintQueue.Jobs <> "0" Then
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "sndrec32 /play /close """ & strWaveFile & """",0,True
Set objShell = Nothing
End if
Next
Change the variables at the beginning to the server, printer, and wave file you want. Save it as WHATEVER.vbs, and double click to run.
However, this is a one-shot deal. If you want, you can schedule it to run every X minutes. If needed, I could modify to have it sleep for a while, then check again.