Batch file problem

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?
12 answers Last reply
More about batch file problem
  1. Did you try it without the quotes around wmplayer.exe?
  2. 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 ?
  3. 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.
  4. 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
  5. 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.
  6. 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
  7. 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.
  8. let me give that a try. Thanks Chugot!
  9. 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!
  10. 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).
  11. 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
  12. Yes, dos commands are great things to know, very powerful when you know what your doing!
Ask a new question

Read More

Configuration Command Prompt Windows 7