1.

Solve : .VBS file that play sound. I don't know how to stop it?

Answer»

Hello, sorry for my poor english.
Sorry if this is not the right place to post about VBscript.

I have the following code, that play a sound without openning any player. The code repeats the sound in LOOP.
I don't know how to STOP the sound. The only way to stop is "kill" the wscript.exe in windows TASK manager.
How can I add a messagebox with an "OK" button to stop the sound ?


Thanks!

Set Sound = CreateObject("WMPlayer.OCX.7")
Sound.URL = "c:\windows\media\notify.wav"
nada = 1
do while nada = 1
wscript.sleep 100
Sound.Controls.play
loop
wscript.sleep (int(Sound.currentmedia.duration)+1)*1000
Solved!

ADDED commands in the first .VBS file to call another .vbs file. This another .vbs file displays a popup on the screen with an only "OK" button. When "ok" button is pressed, the rest of code kill the wscript.exe application.

'This was added in first .vbs file to call the second .vbs file:

Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "inter.vbs"   
Set objShell = Nothing

'This is added in second .vbs file to display message and then kill the wscript.exe after "ok" button is pressed:

x=msgbox ("Message", 0+16+4096, "Tittle")

strComputer = "."
strProcess = "'wscript.exe'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcess )

For Each objProcess in colProcess
   objProcess.Terminate()
NextSeems like it would have been easier to break the loop by Opening a message box and then setting the NADA variable to 0 if they click OK.



Discussion

No Comment Found