I think this is only possible if you have several start commands in the same batch file.
If you try to open several instances of MP3tag then it is not possible as theses instances start independently from each other and then discover that there is already an instance running.
Thanks. I'm not trying to open several instances. I'm trying to open a single instance in this batch file. The failure occurs if there is already in instance open when the batch file starts.
If you start the batch file and there is already an open MP3tag then you do open several instances.
The batch file only knows abouts its very local environment so that one command in the chain can listen to the response of the previous command.
Everything that runs outside this environment is not under control of the batch process.
So as it is not possible to start several instances of MP3tag any attempt to start another instance will fail.
Mp3tag is a windows application but not a command line application.
Once Mp3tag has been started from the command line, the windows process get its own environment and has no further binding to the command process.
Furthermore Mp3tag checks itself if it has been started again.
Mp3tag only takes the new process's parameters, kills the new process, and updates itself with the new parameters.
For example ...
START "" /WAIT notepad.exe
... will wait until notepad has been closed.
That's the same when starting Mp3tag.exe.
Huh, what was the problem, please?
Ah yes I see, the new still invisible Mp3tag process will be killed immediately.
And the command script takes the next step.
You can look for a running Mp3tag process ... and if exist, then kill it.
pslist.exe "Mp3tag" -e 1>NUL 2>NUL
IF %ERRORLEVEL%==0 (ECHO.Mp3tag is running.) ELSE (ECHO.Mp3tag is not running.)
IF %ERRORLEVEL%==0 (pskill.exe "Mp3tag" 1>NUL 2>NUL)
Thanks. That works. Which is a surprise, since nowhere do I see that pslist is supposed to set %errorlevel%.
Kill loses any unsaved work in the app, so I decided to pause instead:
pslist.exe "Mp3tag" -e 1>NUL 2>NUL
REM If Mp3tag already running, manually close before proceeding.
If %ERRORLEVEL%==0 (pause)
Thanks again. This is a big improvement, because it also prevents that command Mp3tag.exe running a different and incompatible version of the app (I have both V2.44 and later) which was occasionally causing false metadata.
I'm glad to help you.
Hmm ... you may rename Mp3tag.exe version 2.44 to another name like "Mp3tag244.exe" and run it under that name, so you can see it in the processlist with that name and decide what to do.
Renaming seems not to change the behaviour of Mp3tag killing the second invocation.
The behavior that I see is that Mp3tag opens with the Alison Krauss album. When Mp3tag is closed, it then opens again with the Freddie Hubbard album. I assume that's what you want.
Thanks but it is not. I asked "Anyone know how to get /WAIT on the START command to work when Mp3tag is already running?" and if you try your example when Mp3tag is already running you'll see your /WAIT fails.