# What language is this? How can I use this script?

**URL:** <https://boards.straightdope.com/t/what-language-is-this-how-can-i-use-this-script/249534>\
**Category:** Factual Questions\
**Created:** [June 9, 2004, 9:55pm UTC](https://boards.straightdope.com/t/what-language-is-this-how-can-i-use-this-script/249534 "2004-06-09T21:55:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ready29003](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@ready29003](https://boards.straightdope.com/u/ready29003)\
**Post date:** [June 9, 2004, 9:55pm UTC](https://boards.straightdope.com/t/what-language-is-this-how-can-i-use-this-script/249534/1 "2004-06-09T21:55:30Z")

</div>

Hi! I am not a programmer, but I am pretending. Please help me.

Microsoft has this little script on their site. I want to run it. Only a couple minor problems:

1. I have no idea what language this is in.
2. I have no idea how to execute this script.

Any help?

[Print Monitor Script](http://www.microsoft.com/technet/community/scriptcenter/printing/scrprn27.mspx)

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.

Extra bonus points if you help me with part 2!

HELP PLEASE!

---

<div class="post-metadata">

**Author:** ![SmackFu](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@SmackFu](https://boards.straightdope.com/u/SmackFu)\
**Post date:** [June 9, 2004, 10:06pm UTC](https://boards.straightdope.com/t/what-language-is-this-how-can-i-use-this-script/249534/2 "2004-06-09T22:06:30Z")

</div>

It looks like Windows scripting, so try putting it in a file that has a .wsh extension. Then you should just be able to double-click it.

---

<div class="post-metadata">

**Author:** ![qshapadooy](https://avatars.discourse-cdn.com/v4/letter/q/c67d28/32.png) [@qshapadooy](https://boards.straightdope.com/u/qshapadooy)\
**Post date:** [June 9, 2004, 10:20pm UTC](https://boards.straightdope.com/t/what-language-is-this-how-can-i-use-this-script/249534/3 "2004-06-09T22:20:03Z")

</div>

> [@ready29003](#):
>
> Hi! I am not a programmer, but I am pretending. Please help me.
> 
> Microsoft has this little script on their site. I want to run it. Only a couple minor problems:
> 
> 1. I have no idea what language this is in.
> 2. I have no idea how to execute this script.
> 
> Any help?
> 
> [Print Monitor Script](http://www.microsoft.com/technet/community/scriptcenter/printing/scrprn27.mspx)  
> 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.
> 
> Extra bonus points if you help me with part 2!
> 
> HELP PLEASE!

Gar, didn’t I just get done doing this for eight hours today. 🙂

```auto

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.

Let me know if you need any other help.

---

<div class="post-metadata">

**Author:** ![ready29003](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@ready29003](https://boards.straightdope.com/u/ready29003)\
**Post date:** [June 10, 2004, 3:00pm UTC](https://boards.straightdope.com/t/what-language-is-this-how-can-i-use-this-script/249534/4 "2004-06-10T15:00:59Z")

</div>

If I had known you were going to do that for me, I wouldn’t have spent 5 hours figuring out how to write a vbscript like that myself.

Thanks a ton! I figured out how to do the sleep thing too. 🙂

Matt
