Batch file problem

nerdoboy

Honorable
Dec 18, 2012
8
0
10,510
Hello, I am trying to start WMplayer, run a playlist and then I want to close WMplayer. My batch file looks like this:

"@echo off
Start wmplayer /fullscreen "c:\windows\test\test.wpl"
taskkill /im "wmplayer.exe"
exit"

Problem is that it never closes WMplayer. Do I need a command to close the playlist first?
 

nerdoboy

Honorable
Dec 18, 2012
8
0
10,510
Yes. I even tried to do a call to a separate bat file called kill.bat. If I run kill.bat (which is just taskkill /im wmplayer.exe) by itself it works perfectly. But if I try to call it from the other bat file it never happens. It's like the first bat file is waiting fro something to happen after it plays the playlist in order for the rest of the batch file to complete.
 

nerdoboy

Honorable
Dec 18, 2012
8
0
10,510


What I am trying to accomplish is to run wmplayer, fullscreen and play a two video files. When it is over I want to go back to the desktop with nothing happening.

I killed the quotes and it still has no effect. When the playlist is through it dumps out of full screen mode and i am left with the windows media player open and the cmd window open waiting to complete its task
 

nerdoboy

Honorable
Dec 18, 2012
8
0
10,510


I tried the pause just now but no joy. I do agree that it seems to be waiting for the playlist to end.

thanks for the input guys
 

chugot9218

Honorable
I just tested this on my machine and I think I found the problem, because the program is running a file, I don't think it closes properly with the taskkill command. You can add a /f to force it to close, but I think it will just shut it down while the vids are playing. You have to insert a delay that is longer than the videos, and then do the taskkill command.
 

nerdoboy

Honorable
Dec 18, 2012
8
0
10,510
OK it is fixed. I used the ping trick to create a delay slightly longer than the length of the video and then I added the /f to force the termination with taskkill. Note: the /f has to go before the /im

here is the working form

@echo off
Start wmplayer /fullscreen "c:\Program files\Windows Media player\logo.wmv"
PING 1.1.1.1 -n 1 -w 12500 >NUL
taskkill /f /im wmplayer.exe
exit

Thanks to das and chugot for the help!
 

chugot9218

Honorable
NP, it is helpful to use pause between your commands to see if it is giving you any response in the CMD prompt, same way you use dialog boxes to debug code. If you place the pause after the taskkill command you will see the error message I found (I believe).
 

nerdoboy

Honorable
Dec 18, 2012
8
0
10,510
good point and I will do that in the future. I love bat files. They are a throwback to a more primitive day for sure but I enjoy getting a little manual control on my computer