Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I found some of this code:
@echo off
:top
SET /A RAND=%RANDOM% %%6
if %RAND%==1 set "file="%windir%\WinSxS\amd64_microsoft-windows-shell-sounds_31bf3856ad364e35_10.0.17134.1_none_fc93088a1eb3fd11\Windows Exclamation.wav""
if %RAND%==2 set "file="%windir%\WinSxS\amd64_microsoft-windows-shell-sounds_31bf3856ad364e35_10.0.17134.1_none_fc93088a1eb3fd11\tada.wav""
if %RAND%==3 set "file="%windir%\WinSxS\amd64_microsoft-windows-shell-sounds_31bf3856ad364e35_10.0.17134.1_none_fc93088a1eb3fd11\Windows Critical Stop.wav""
if %RAND%==4 set "file="%windir%\WinSxS\amd64_microsoft-windows-shell-sounds_31bf3856ad364e35_10.0.17134.1_none_fc93088a1eb3fd11\Windows Error.wav""
if %RAND%==5 set "file="%windir%\WinSxS\amd64_microsoft-windows-shell-sounds_31bf3856ad364e35_10.0.17134.1_none_fc93088a1eb3fd11\Windows Background.wav""
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^) <------
  echo Sound.URL = "%file%" <------
  echo Sound.Controls.play <-----
  echo do while Sound.currentmedia.duration = 0 <-----
  echo wscript.sleep 100 <-----
  echo loop <-----
  echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs <-----
start /min sound.vbs <-----
ping localhost -n 1 >NUL
goto top
:End

The bits with the arrows is the bit I'm not sure about.
Here is my error.Here is a picture[^]

What I have tried:

Well... Nothing.. I don't know what to do.
Posted
Updated 23-Sep-18 6:30am
v2

1 solution

Your DOS batch file creates a .VBS file and puts a bit of code in it. Post the content of that sound.vbs file. I get the feeling the batch file part isn't written correctly and it's putting garbage code into the .VBS file.
 
Share this answer
 
Comments
Member 13985992 23-Sep-18 14:04pm    
The batch part is the bit I made... But it said from my knowledge that this bit:
echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
        ^
it thought it should be end of statement so just echo wscript.sleep
Dave Kreskowiak 23-Sep-18 15:02pm    
Once again, look in sound.vbs and post that here. Hit the green "Improve question" link to get back into the editor and add the code.

I'm willing to bet what you think is in that file is not what you expect.
Dave Kreskowiak 23-Sep-18 15:23pm    
In the picture you linked to, it's complaining about line 2.

Also, I don't know where you got this code from or what you expect it to do.
Member 13985992 24-Sep-18 2:43am    
it was a stack overflow post: https://stackoverflow.com/questions/23313709/play-invisible-music-with-batch-file
here is what they gave the person:
@echo off
set "file=track12.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.Controls.play
echo do while Sound.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
start /min sound.vbs
Dave Kreskowiak 24-Sep-18 10:44am    
OK, it's complaining about the line where you set the Sound.URL property. If your file path, set higher up in your batch file, has a single set of quotes around it, this isn't going to work. To put quotes in a string in VBScript requires line of code to look like this:
    String path = """C:\Program Files\Something"""

Two quote marks escape into a single quote mark in the resulting string. You end up with a string (with quotes) like this:
    "C:\Program Files\Something"


To get that same effect in your batch file, the Sound.URL line has to look like this:
    echo Sound.URL = ""%file%""

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900