@echo off
for /f "delims=" %%a in ('dir /a-d/b *.jpg') do (
if not [%%a]==[] start "" file.exe
)
echo end...
pause
将以下内容存为monitor.bat:
@echo off
:S
@choice /t 60 /d Y /m "是否继续监控?"
@if %errorlevel%==2 goto E
@for /f "delims=" %%i in ('dir /b %1\*.jpg') do (
if "%%i"=="" (
@goto E
) else (
@start %2
)
goto S
:E
@exit
运行时可以输入monitor c:\temp\AAA file.exe
下面是路径和执行程序写死的monitor.bat,只要路径和程序正确,双击运行即可。
@echo off
:S
@choice /t 60 /d Y /m "是否继续监控?"
@if %errorlevel%==2 goto E
@for /f "delims=" %%i in ('dir /b c:\AAA\*.jpg') do (
if "%%i"=="" (
@goto E
) else (
@start file.exe
)
goto S
:E
@exit