Sign in with
Sign up | Sign in
Your question

Batch file problem

Tags:
  • Configuration
  • Command Prompt
  • Windows 7
Last response: in Windows 7
Share
December 18, 2012 5:01:43 PM

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?

More about : batch file problem

a b $ Windows 7
December 18, 2012 5:08:42 PM

Did you try it without the quotes around wmplayer.exe?
m
0
l
a b $ Windows 7
December 18, 2012 5:14:22 PM

No quotes and don't forget you will need to run the batch file as an admin.

But why open up wmplayer and then kill it ?
m
0
l
Related resources
Can't find your answer ? Ask !
December 18, 2012 5:16:55 PM

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.
m
0
l
December 18, 2012 5:20:50 PM

das_stig said:
No quotes and don't forget you will need to run the batch file as an admin.

But why open up wmplayer and then kill it ?


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
m
0
l
a b $ Windows 7
December 18, 2012 5:21:28 PM

Put a pause in after opening WMP, and see if it gets to that point, I don't know if it is possibly waiting for the playlist to complete or something but that'd be my guess.
m
0
l
December 18, 2012 5:25:21 PM

chugot9218 said:
Put a pause in after opening WMP, and see if it gets to that point, I don't know if it is possibly waiting for the playlist to complete or something but that'd be my guess.


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
m
0
l
a b $ Windows 7
December 18, 2012 5:31:06 PM

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.
m
0
l
December 18, 2012 6:12:31 PM

let me give that a try. Thanks Chugot!
m
0
l
December 18, 2012 6:47:05 PM

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!
m
0
l
a b $ Windows 7
December 18, 2012 6:47:29 PM

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).
m
0
l
December 18, 2012 6:50:20 PM

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
m
0
l
a b $ Windows 7
December 18, 2012 6:59:28 PM

Yes, dos commands are great things to know, very powerful when you know what your doing!
m
0
l
!