我有以下批处理文件
SET logfile="C:\Reports\logbatch.log"
@echo off
@echo Starting Script at %date% %time% >> %logfile%
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe"
"C:\Users\mypc\source\repos\WebS\WebS\Start_Master.py"
@echo finished at %date% %time% >> %logfile%
pause
该Start_Master.py包含位于与Start_Master.py同一文件夹中其他几个脚本
如果我手动运行它,批处理文件有效。
当我创建任务并且任务自动或手动运行时,我发现它无法打开文件
python: can't open the file 'script1.py' No such file or directory
python: can't open the file 'script2.py' No such file or directory
python: can't open the file 'script3.py' No such file or directory
尝试:
SET logfile="C:\Reports\logbatch.log"
@echo off
@echo Starting Script at %date% %time% >> %logfile%
cd "C:\Users\mypc\source\repos\WebS\WebS\"
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe"
"C:\Users\mypc\source\repos\WebS\WebS\Start_Master.py"
@echo finished at %date% %time% >> %logfile%
pause
尝试将CWD(当前工作目录)更改为Start_Master.py所在的目录
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句