1

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)
Alfie Atkinson
  • 58
  • 1
  • 10

3 Answers3

2

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
  • I just tried adding this to my code, and it didn't work, however i used this code directly in command prompt and it worked fine, so I'm really stumped as to what the problem is. – Alfie Atkinson Apr 15 '19 at 11:32
  • I even tried making a completely different file with just this code in it and it still didn't work, is it a problem with the use of a batch file? – Alfie Atkinson Apr 15 '19 at 11:40
  • There shouldn't be a difference if you save the file as plain ascii/ansi –  Apr 15 '19 at 11:43
  • How do I find out whether it is or not? – Alfie Atkinson Apr 15 '19 at 11:53
  • That dpends on your editor, check settings before saving. –  Apr 15 '19 at 12:35
  • There is nothing in the text that would differ between ascii/ansi, here the batch file runs (with a local file) and as well in the console. –  Apr 15 '19 at 15:30
0

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 ***************************************
Hackoo
  • 18,337
  • 3
  • 40
  • 70
  • This also doesn't seem to solve my problem, I don't think the problem is with playing the video, because all of the methods work in the command line, they just don't seem to work in the batch file. the closest I've got is playing the audio of the video in the background – Alfie Atkinson Apr 16 '19 at 08:25
  • @AlfieAtkinson Check my last edit and tell me how it works on your side ? – Hackoo Apr 16 '19 at 08:51
  • Okay so it works fine with the video that you have linked, however it dowsn't work for my video? which is located in (res\myvideo.mp4) relative to the file, so I really don't know whats going on :/ – Alfie Atkinson Apr 16 '19 at 13:54
0
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.

aritz331_
  • 68
  • 2
  • 9