Play a song 3 times using a batch file on VLC - loops

I'm a beginner in this script, even though I know some basic vanilla JS. I want to make a batch file that could run 3 times...
Here is what I have tried, batch file just runs and closes. I'm not sure why this happens? Can I make it work?
#echo off
for /l %%v in (1,1,3) do (
set "file=AKАТИСТ светом Архангелу МИХАИЛУ - AKATIST.mp3"
( echo Set Sound = CreateObject("VLCplayer.xspf"^)
echo Sound.URL = "D:\AKАТИСТ светом Архангелу МИХАИЛУ - AKATIST.mp3"
echo Sound.settings.volume = 76
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo Wend
run Sound
)
)

Related

Creating music with batch

i wanted to know if there is some way of doing music with batch, not just opening a mp3 file from cmd, but commands to do notes or something like that. If there really isn't how to do it, i understand.
batch can play music by creating and starting a vbs script to Leverage the internal windows media player.
Note: In all the below scripts, the variable %sounds% refers to the folder your sound scripts are located, and must be defined.
The core of playing music is the following Batch Script:
#Echo off & REM MusicPlayer.bat
Set "MusicPath=%~1" & REM Full Path for the music file
Set "vol=%~2" & REM Volume as number between 0 and 100
Set "LoopTF=%~3" & REM 'paramater 3 as 'true' or 'false' determines if the track is to be looped.
(
PUSHD %sounds%
%= Change to the directory your sound files are located =%)
::: Ensure no Conflict with the Previous Script.
IF exist PlayMusic.vbs (
DEL PlayMusic.vbs
)
::: Creates a vbs Script to launch the music (Occurs without any visual indication or prompting)
(
echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%MusicPath%"
echo Sound.settings.volume = %vol%
echo Sound.settings.setMode "loop", %LoopTF%
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
echo Sound objTS = Nothing 'Destroy the object.
)>PlayMusic.vbs
start /min PlayMusic.vbs
(
POPD
%= Return to your Previous Directory =%)
::: Exit the Launcher and return to Previous batch program.
GOTO :EOF
The above script is called with 3 parameters as Remarked.
Another Vbs can be used to Monitor the batch's status and call a batch script to stop the music when the batch is closed:
#Echo off & REM Monitor.bat
(
ECHO Set objWMIService = GetObject ("winmgmts:"^)
ECHO Set proc = objWMIService.ExecQuery("select * from Win32_Process Where Name='cmd.exe'"^)
ECHO DO while proc.count ^> 0
ECHO Set proc = objWMIService.ExecQuery("select * from Win32_Process Where Name='cmd.exe'"^)
ECHO if proc.count ^< 1 then exit do
ECHO wscript.sleep 1500
ECHO loop
ECHO Set WshShell=createobject("wscript.shell"^)
ECHO WshShell.run "%sounds%\KillMusic.bat", 0, true
)>%sounds%\MusicMonitor.vbs
start %sounds%\MusicMonitor.vbs
Goto :EOF
The above script creates a hidden vbs that fetches the number of instances of cmd.exe via the objWMIService.ExecQuery. This occurs during a loop, with the break condition being 0 open cmd.exe windows. A sleep is built into the loop to reduce the frequency of calls to the WMI service, as these are very resource intensive. When the loop break occurs, it starts the killmusic.bat program in a hidden state.
The below script "KillMusic.bat" is called either directly in your quit label or by the vbs monitor when it determines Cmd.exe is no longer running. DoMonitor is a variable that is changed in your main script prior to killmusic being called. 1 indicates the monitor should be restarted, and is used when killmusic.bat stops a currently playing song to start a new song. Monitor is a Variable containing the path to Monitor.bat
#ECHO OFF & REM KillMusic.bat
taskkill /pid WScript.exe /f /t >nul
IF exist "%sounds%\PlayMusic.vbs" (
DEL /Q "%sounds%\PlayMusic.vbs"
)
Timeout 1 > nul
IF "%DoMonitor%"=="1" GOTO reset
GOTO :EOF
:reset
CALL "%Monitor%"
GOTO :EOF
These three programs can be seen in effect here.

How do i get a batch script to show real time progress bar, while waiting for another script to finish?

Hi im not really good in writing batch scripts, im new to this, i really need help,
The script i have needs to do an unattended installation,
i got that part to work, what i need is to show a progress bar for the users to see the progress of the installation,
the script i have is below:
#echo off
echo --------------------------------------------------------------
echo --------------------------------------------------------------
echo Software is installing......
echo.
echo please wait, do not close!!
echo.
C:\files\gw18\win32\install.bat /unattended
cls
i found this really cool progress bar script, i need help to make it work with the above
#echo off
setlocal EnableDelayedExpansion
set Counter=0
set Schalter=2
set Width=0
:1
title Animation Box - Installation
set /a Counter=%Counter% + 1
set /a Display=%Counter% / 2
FOR /L %%A IN (1,1,%Display%) DO (
set Display=!Display!²
)
cls
echo Progress... %Counter%%%
echo ²!Display:~2,47!
ping localhost -n 1 >nul
if "%Counter%" == "100" goto :1-End
goto :1
:1-End
echo.
echo Installation complete.
pause >nul
Or any progress bar code that will work
Thank you in advance :)
What I would recommend doing for the progress bar script, is make it so that the installer outputs a text file every time it completes a task. For example, when it completes MOVE file.exe "C:\Program Files\Application", echo EXE Move Completed. > 1.txt.
Then, the progress bar script would constantly watch for those files, then update the progress bar accordingly. Example:
:watch1
if exist 1.txt goto update1
goto watch1
:update1
cls
echo Progress: 0========== 0
DEL 1.txt
goto watch2
:watch2
if exist 2.txt goto update2
goto watch2
And so on.
So every time the progress bar script finds a new file outputted by the installer, it adds a little bit more to the progress bar.
Hope this helped.

vbscript opens mp4 in wmplayer, but only audio plays

I'm trying to simply open a video in full screen using a batch file, I realised this wasn't possible so I included code to make it write to vbscript instead and then later on execute the vbscript code.
I'm running windows 10, and I have another script running an mp3 file that works fine.
This is what my batch file is writing to the vbscript
set "file2=res\FORTNITESKINS.mp4"
( echo Set wmp = CreateObject("WMPlayer.OCX"^)
echo Video.URL = "%file2%"
echo Video.Controls.play
echo do while Video.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Video.currentmedia.duration^)+1^)*1000
echo set WshShell = WScript.CreateObject("WScript.Shell"^)
echo WScript.Sleep 1000
echo WshShell.SendKeys "%{ENTER}") >video.vbs
This is how I execute the vbscript
start video.vbs
The video does not open, only the audio plays, and wmplayer doesn't even open minimized, nor can I find it in task manager.
I have also tried this,
set "file2=res\FORTNITESKINS.mp4"
( echo Set Video = CreateObject("WMPlayer.OCX"^)
echo Video.openPlayer("%file2%"^)
echo set WshShell = WScript.CreateObject("WScript.Shell"^)
echo WScript.Sleep 1000
echo WshShell.SendKeys "%{ENTER}") >video.vbs
but it gives the error:
Line: 2
Char: 1
Error: 0xC00D1329
Code: C00D1329
Source: (null)
Why don't you use wmplayer directly with proper command-line-parameters ?
#Echo off
set "file2=res\FORTNITESKINS.mp4"
set wmplayer="%ProgramFiles(x86)%\Windows Media Player\wmplayer.exe" /prefetch:1
%wmplayer% "%file2%" /fullscreen
You can do it like this example :
#echo off
Mode 70,3 & color 0B
echo(
Set "Title=Playing videos with Windows Media Player"
Title %Title%
echo %Title%
Set "URL-FILE=http://1290922571.rsc.cdn77.org/movies/Superman-Unbound-2013-FRENCH.mp4/playlist.m3u8"
Start "%Title%" wmplayer /fullscreen "%URL-FILE%"
Timeout /T 2 /NoBreak>nul
EDIT :
#echo off
Mode 70,3 & color 0B
echo(
Set "Title=Playing videos with Windows Media Player"
Title %Title%
echo %Title%
Set vbs_video=%temp%\vbs_video.vbs
Set video=http://1290922571.rsc.cdn77.org/movies/Superman-Unbound-2013-FRENCH.mp4/playlist.m3u8
Call :Play %video%
Timeout /T 2 /NoBreak>nul & Exit
REM ***************************************
:Play <video>
(
echo Set Video = CreateObject("WMPlayer.OCX"^)
echo Video.openPlayer("%~1"^)
echo set WshShell = CreateObject("WScript.Shell"^)
echo WScript.Sleep 3000
echo WshShell.SendKeys "%%{ENTER}"
)>"%vbs_video%"
Start "video" "%vbs_video%"
exit /b
REM ***************************************
set "file2=F:\ull\path\to\res\FORTNITESKINS.mp4"
You must enter the full path to the file for the script to work. Including the drive letter and the path to the current folder.

Using For loop in CMD to get user input and use that to create .txt files

I am trying to use for loop in CMD to 1) obtain user input as a number 2) use that number to create "n" number of .txt files starting from 1.txt and ending at n.txt.
I have this so far:
#echo off
set /p n="Enter a number:"
for %%n%% in (1, 1, %%n%%) echo %%n%% > %%n%%.txt
I played around with the "%" since it is in a batch file.
If I just use this:
#echo off
set /p n="Enter a number:"
echo %n% was created
It will says "input" was created , if I add the "> %n%.txt" then it will create a file called n.txt with whatever the echo line says inside the .txt file and does not echo the result on the cmd screen.
Keep in mind that I am new to this, been playing with this particular challenge question for a few days and to no avail.
Any input is appreciated!
set /p n="Enter a number:"
echo %n% was created
for /l %%z in (1, 1, %n%) do echo %%z > %%z.txt
I guess typing randomly doesn't work so well.
**Alternative use for for loop. Try this code. Simple use of batch command which will work for you.
set /p in="Enter a number:"
set /a n = 1
set /a count = %in% + 1
:loop
echo %n%
echo %n% > %n%.txt
set /a n = %n% + 1
IF %n% LSS %count% ( goto loop)
goto rest
:rest

Problems when writing a batch file to repeat a paragraph containing %PATH%

I have written the following batch file that will write 100 paragraphs into a .bat file with incremental number changes to the file names referred.
for /l %%N in (1 5 500) do (
echo cd /D "C:\batch"
echo set PATH=C:\batch; &PATH%
echo echo Simulation 'g=0.00%%N.pre' started...
echo call %SOLVERQSP%-fp 1 -nt 3 ^
"C:\batch\0.00%%N.pre" > "C:\batch\g=0.00%%N.out"
echo echo Simulation 'g=0.00%%N' finished...
echo echo.
The problem is that the batch file is not created when the %PATH% and %SOLVERQSP% commands are present. If i remove these the script runs fine. Any suggestions of where I am going wrong or how I can avoid this
You should use some quotes and avoid the caret in your case
for /l %%N in (1 5 500) do (
echo cd /D "C:\batch"
echo set "PATH=C:\batch; %PATH%"
echo echo Simulation 'g=0.00%%N.pre' started...
echo call %%SOLVERQSP%%-fp 1 -nt 3 "C:\batch\0.00%%N.pre" > "C:\batch\g=0.00%%N.out"
echo echo Simulation 'g=0.00%%N' finished...
echo echo.
)
Just escape the % by doubling them:
echo set PATH=C:\batch;%%PATH%%

Resources