0

I'm very new to using Batch files, and have ran into a problem that Googling hasn't been able to solve. I hope someone can assist me with this, because it's quite a doozy. My intentions is to have a Front-End program for emulation and a Windows Media Player playlist open simultaneously, to allow for menu music to be played, and then have the WMP close when I start a game, and open up again when I close the game, returning to the Front-End. The litany of issues I've encountered are:

  1. The Front-End opens fullscreen, and has priority. I can open WMP simultaneously, but once the Front-End is running, it seems to negate any other files/programs from starting/closing.
  2. The Front-End lists games for me. When I select one, it minimizes the Front-End into the background, and launches the emulator, that then runs the game. When I exit the game, it relaunches the Front-End. The Emulator itself also negates most files/programs from launching. When I did get a hotkey setup to launch a .bat file that opens WMP after exiting a game, it would launch WMP successfully, but also pause the Emulator, and prevent it from exiting properly.
  3. To launch WMP as a playlist that's already playing music on shuffle, I start as "AP1.wpl", which is the file of the playlist, but the only way to exit is to taskkill "wmplayer.exe", so they're not tagged as the same program.
  4. The Front-End's .exe doesn't launch via a .bat file. So my workaround was to create a .vbs that shortcuts it's launch as a hotkey, and include the .vbs in my .bat, so this limits me on tagging WMP with the Front-End, but since it doesn't ever actually close, and blocks all commands while it's open, I don't think it matters much.

I guess that's really all the issues worth mentioning to explain the situation.

The one idea I do have, is that when I select a game in the Front-End, it minimizes and opens a command prompt for a brief 2-3 seconds, then launches the Emulator/Game. This brief opening does allow me to launch and close programs before the Emulator shuts me back out. If I could just tie the closing and opening of WMP to the command prompt, so that when I launch the Front-End, WMP launches, and when I launch a game, it closes WMP as soon as the CMD opens. When the game is exited (as well as the cmd), it would launch the .wpl playlist. It would have to be this sort of loop, dependent on when the CMD is opened/closed. So far, this is what I have going (it's not much):

@echo off
start hotkey1.vbs
C:\AP\AP1.wpl

The .vbs is launching the Front-End, and AP1.wpl is the playlist. And somehow wmplayer.exe has to be taskkill'd via the appearance and disappearance of cmd.exe, of it's own accord.

  • The logic I'm using isn't much, most of this is just the theory of what I want to do. The totality of my batch file is what I've listed above. This is the .vbs: Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.SendKeys "^%5" It's all pretty much a clean slate if you have any ideas. – BNM51306 Aug 9 '17 at 4:55
  • I appreciate your help so far! It's been a trying experience just trying to think through all of this. I am super unfamiliar with pretty much all of this, and only know some of the simplest batch syntax. The .vbs was just something I googled. I don't think I want to go down the road of editing any program scripts. I'd be ecstatic if my intentions could be contained to just a .bat – BNM51306 Aug 9 '17 at 5:24
  • I have no clue about vbs and I'm not sure I got your whole problem, but may it be an idea to query <code>tasklist</code> via batch file to see if the emulator and mediaplayer are running? – Florian Straub Aug 24 '17 at 7:51

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.