How would you play a wav file from within a VBScript? E.g. I am using CRT,
a telnet/ssh client that supports VBScript, and I have a trigger setup based
upon incoming text. The next thing I need to do is play a wave file when
the trigger is fired.

Re: Playing a WAV file by Torgeir

Torgeir
Fri Apr 30 13:51:04 CDT 2004

Buckwheat wrote:

> How would you play a wav file from within a VBScript? E.g. I am using CRT,
> a telnet/ssh client that supports VBScript, and I have a trigger setup based
> upon incoming text. The next thing I need to do is play a wave file when
> the trigger is fired.
Hi

Set oShell = CreateObject("Wscript.Shell")
sWaveFile = "%windir%\media\ding.wav"
oShell.Run "sndrec32.exe /embedding /play /close """ _
& sWaveFile & """", 0, True


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx

Re: Playing a WAV file by Buckwheat

Buckwheat
Fri Apr 30 15:59:15 CDT 2004

Is there a tighter, cleaner way than launching another instance of the
shell? Performance is an issue.


"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:O$DT1QuLEHA.3904@TK2MSFTNGP09.phx.gbl...
> Buckwheat wrote:
>
> > How would you play a wav file from within a VBScript? E.g. I am using
CRT,
> > a telnet/ssh client that supports VBScript, and I have a trigger setup
based
> > upon incoming text. The next thing I need to do is play a wave file
when
> > the trigger is fired.
> Hi
>
> Set oShell = CreateObject("Wscript.Shell")
> sWaveFile = "%windir%\media\ding.wav"
> oShell.Run "sndrec32.exe /embedding /play /close """ _
> & sWaveFile & """", 0, True
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/community/scriptcenter/default.mspx



Re: Playing a WAV file by Michael

Michael
Fri Apr 30 23:02:43 CDT 2004

> Is there a tighter, cleaner way than launching another instance of the
> shell? Performance is an issue.


Define what you interpret in that code as "launching another instance of the
shell"...

Creating/using an instance of WScript.Shell is not a performance problem...


--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Re: Playing a WAV file by Buckwheat

Buckwheat
Mon May 03 08:09:27 CDT 2004

It is a performance issue in the sense that it takes 2-4 seconds from the
time the respective section of code is triggered to when the sound actually
begins playing. The fact that the code is instantiating an instance of the
object leads me to believe that, like in UNIX/LINUX, a new instance of the
shell is being created, and thus, there is unnecessary overhead causing the
delay. I need a method which will play the sound instantly.


"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:uWJvoEzLEHA.556@tk2msftngp13.phx.gbl...
> > Is there a tighter, cleaner way than launching another instance of the
> > shell? Performance is an issue.
>
>
> Define what you interpret in that code as "launching another instance of
the
> shell"...
>
> Creating/using an instance of WScript.Shell is not a performance
problem...
>
>
> --
> Michael Harris
> Microsoft.MVP.Scripting
> Sammamish WA US
>



Re: Playing a WAV file by Torgeir

Torgeir
Mon May 03 14:28:36 CDT 2004

Buckwheat wrote:
> It is a performance issue in the sense that it takes 2-4 seconds from the
> time the respective section of code is triggered to when the sound actually
> begins playing. The fact that the code is instantiating an instance of the
> object leads me to believe that, like in UNIX/LINUX, a new instance of the
> shell is being created, and thus, there is unnecessary overhead causing the
> delay. I need a method which will play the sound instantly.
Hi

I would think that delay is cased by the startup of the
media player, and not the shell.


If a beep (or a series of beeps) is good enough, this
might work better for you:


Set oShell = CreateObject("Wscript.Shell")

MsgBox "one Beep"
' one Beep
'Beep 1, 0

MsgBox "3 beeps with a very short pause between each"
' 3 beeps with a very short pause between each
Beep 3, 2

MsgBox "3 beeps with a longer pause between each"
' 3 beeps with a longer pause between each
Beep 3, 4


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


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx