0

I have 2 small batch files that change the target location of a junction point (mkref /d), in order to switch between 2 iTunes libraries.

It works well, but I would like it to stop if iTunes is already running - as iTunes will overwrite the library in the wrong target folder if I change the junction while it is running.

Is there a way to quit or pause the batch file if iTunes.exe is running?

mtone
  • 11,700

1 Answers1

2

Try adding the following to the beginning of your batch files:

tasklist /fi "Imagename eq itunes.exe" 2>NUL | find /i /n "itunes.exe">NUL
if "%ERRORLEVEL%"=="0" exit

For more information, see the documentation on the tasklist and find commands.

Indrek
  • 24,874