I have my vbscript working…now I just need it to play a wav file.
How do I do that? I have search and searched. Instead of “A Job is printing” I want it to play a .wav file. Please help. thanks.
Here is my script:
WARNING_THRESHOLD=0
Const PAUSETIME = 500
For i = 1 to 120000
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\” & strComputer & “\root\cimv2”)
Set colPrintQueues = objWMIService.ExecQuery _
(“Select * from Win32_PerfFormattedData_Spooler_PrintQueue Where Name <> ‘_Total’”)
For Each objPrintQueue in colPrintQueues
If objPrintQueue.Jobs > WARNING_THRESHOLD Then
Wscript.Echo objPrintQueue.Name & “A Job is Printing!”
End If
NEXT
Wscript.Sleep PAUSETIME
Next
Set oShell = CreateObject("Wscript.Shell")
Beep 1, 0
Sub Beep (n, wait)
For i = 1 To n
oShell.Run "%comspec% /c echo " & Chr(7), 0, False
Wscript.Sleep wait*100
Next
End Sub
Option Explicit
Dim strComputer, strTargetPrinter, strWaveFile, i, j, LoopVariable
Dim objWMIService, objPrintQueue, colPrintQueues, objShell
Const PAUSETIME = 500
strTargetPrinter = "MLOCAL2"
strWaveFile = "c:\statlabelsoundscript\buzzer.wav"
LoopVariable = 1
Do Until LoopVariable = 0
strComputer = "."
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
Wscript.Sleep PAUSETIME
LOOP
Any other ideas for how to make it play until someone hits OK or something?