Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 检测到文件时运行.BAT_Batch File - Fatal编程技术网

Batch file 检测到文件时运行.BAT

Batch file 检测到文件时运行.BAT,batch-file,Batch File,尝试创建.bat文件以检测文件并执行命令 目前我正在手动运行.bat文件,希望它在创建检测文件时自动运行 "C:\Users\Desktop\\Garment Label\CSVProcessor\CSVProcessor.Host.exe" CSVConfig "C:\Users\Desktop\Label\Revised 150718\test2.csv" DEL "C:\Users\Desktop\Label\Revised 150718\test2.csv" 谢谢你不确定你要检查什

尝试创建.bat文件以检测文件并执行命令

目前我正在手动运行.bat文件,希望它在创建检测文件时自动运行

"C:\Users\Desktop\\Garment Label\CSVProcessor\CSVProcessor.Host.exe"  CSVConfig 
"C:\Users\Desktop\Label\Revised 150718\test2.csv"
DEL "C:\Users\Desktop\Label\Revised 150718\test2.csv"

谢谢你

不确定你要检查什么文件,或者你是否想让它持续运行并删除文件,所以我给你两个选项

如果文件不存在,请关闭批处理

:retest
if not exist "C:\Users\Desktop\Label\Revised 150718\test2.csv" (
goto :NoFile
) else (
    DEL "C:\Users\Desktop\Label\Revised 150718\test2.csv"
    Echo Deleting file
    goto :retest
)
:NoFile
循环并不断删除文件(如果存在),在循环之间等待10秒

:retest
if not exist "C:\Users\Desktop\Label\Revised 150718\test2.csv" (
timeout 10
goto :retest
) else (
    DEL "C:\Users\Desktop\Label\Revised 150718\test2.csv"
    Echo Deleting file
    goto :retest
)

你的问题是什么?请准确点!关于此任务的计划任务如何?您好,我想检查文件test2是否存在,如果存在,请运行CSVProcessor.Host.exe并删除文件。然后将其置于
)else(
行)下以运行您的exe。