Batch file: Find out what program started?

April 7, 2010 at 11:11:07
Specs: Windows 7

I'm working with this batch file where i'm
starting a .wav file with the "start" command.
This open the program associated with .wav
files. Now, how can i find out the program that
start, and close it after the .wav file is done
playing. I want this to work on different
systems where you don't know what programs
are installed.

Anyway, any help greatly appreciated.

See More: Batch file: Find out what program started?

Report •

April 7, 2010 at 11:29:24
Better idea:
start /min "" "%programfiles%\windows media player\mplayer2" /play /close "some.wav"

Report •

April 7, 2010 at 12:14:35
The problem is that not everyone has Windows media player
installed, and I would really like it to work on more computers
than just mine. I have tried with "assoc" and "ftype" command
to get a search path like this in my case:

Media Player\wmplayer.exe" /Ope
n "%L"

I have tried with "FOR" command in combination with "ftype"
to try to get wmplayer.exe as result but without any luck.
Then it would just be to use "taskill".

Report •

April 7, 2010 at 12:14:36
actually, that's a pretty good question, imo. One way would be to read the registry "associations", which i don't know what the key is offhand. There's probably a better way than that, maybe using tasklist, but not sure. To end a gui program is not so simple, you would, again, have to use tasklist (search for the associated program, making sure it's the correct instance in case it's running more than one instance), then use taskkill to stop it. I guess taskkill is "smart" enough to terminate all the child processes and dlls etc.
-- edit oops: my response crossed in the mail, looks like you already figured out as much or more than i can tell you.

Report •

Related Solutions

April 7, 2010 at 13:22:28
Well, if you just want to bring up the associated player, just "run" the WAV file.

Good luck determining when the player is done playing the WAV, though. (Assuming whatever's associated even plays the file on load.)

WMP should be pretty safe; it's installed with Windows by default. If that's insufficient, your best bet would probably be to write a "real" program to play the audio.

Report •

April 7, 2010 at 13:29:23
Start file -> program starts -> don't know what program -> find
out what program -> close that program.

This "program" can be different on different computers because
of file associations.
How to do this?

Report •

April 7, 2010 at 13:35:53
find out what program -> close that program.
Here's a theoretical question: Let's say you discover Winamp plays wav files. There are two copies of Winamp running. Which one do you close?

Report •

Ask Question