views:

55

answers:

1

My current .bat file is as follows:

@echo off
rem iTunes
tasklist /FI "IMAGENAME eq itunes.exe" /FO CSV > "C:/ForStartingStuff/ForItunes.log"
FOR /F %%A IN (' "C:/ForStartingStuff/ForItunes.log" ') DO IF %%~zA EQU 0 GOTO end
cd "C:\Program Files (x86)\iTunes"
:end
taskkill /im notepad.exe
del "C:/ForStartingStuff/ForItunes.log
rem WC3 Banlist
tasklist /FI "IMAGENAME eq WC3Banlist.exe" /FO CSV > "C:/ForStartingStuff/ForWC3Blist.log"
FOR /F %%A IN (' "C:/ForStartingStuff/ForWC3Blist.log" ') DO IF %%~zA EQU 0 GOTO end
cd "C:\Program Files (x86)\WC3Banlist"
start WC3Banlist.exe
:end
del "C:/ForStartingStuff/ForItunes.log
rem Warcraft3
tasklist /FI "IMAGENAME eq wc3.exe" /FO CSV > "C:/ForStartingStuff/ForWarcraft.log"
FOR /F %%A IN (' "C:/ForStartingStuff/ForWarcraft.log" ') DO IF %%~zA EQU 0 GOTO end
cd "C:\Program Files (x86)\Warcraft III"
start war3.exe
:end
exit

My goal was to have something that opened the program only if they were not open already. This works great, but the one problem is that I have to manually close the notepad windows that open to read the For****.log files. Is there any way to make these things automatically close? BTW I am running vista.

A: 

Try removing the spaces in the fileset of your FOR statement. For example:

FOR /F %%A IN ("C:/ForStartingStuff/ForWarcraft.log") DO ...

instead of

FOR /F %%A IN (' "C:/ForStartingStuff/ForWarcraft.log" ') DO
ars

related questions