我当前的.bat文件如下:
@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
我的目标是只有在程序尚未打开的情况下才能打开程序。这很好用,但一个问题是我必须手动关闭打开的记事本窗口才能读取For ****。日志文件。有没有办法让这些东西自动关闭?顺便说一下,我正在运行vista。
答案 0 :(得分:1)
尝试删除FOR
语句的文件集中的空格。例如:
FOR /F %%A IN ("C:/ForStartingStuff/ForWarcraft.log") DO ...
而不是
FOR /F %%A IN (' "C:/ForStartingStuff/ForWarcraft.log" ') DO