[BAT]批处理脚本双击可运行,但在定时计划任务中无法执行(当前工作路径不对导致的)
2013-09-17 15:19
911 查看
一开始,红色部分我是用set AutoPath=%cd%,双击可执行,但是将这个批处理脚本放在定时任务中无法执行,后来发现在定时执行的时候,当前工作路径不是批处理脚本所在的路径,而是C:/Windows/System32,所以需要用以下方法改变一下当前工作路径。
@echo off
color 0a
echo autotest beginning,Please Wait... ...
set AutoPath=%~dp0
%AutoPath:~0,2%
pushd %AutoPath%
cd /d %AutoPath%
set JmeterPath=..\..\..\
echo AutoPath=%AutoPath%
echo JmeterPath=%JmeterPath%
forfiles /p %AutoPath%Result /m *.jtl -d -7 /c "cmd /c del /f @path">nul 2>nul
forfiles /p %JmeterPath%extras /m *.html -d -7 /c "cmd /c del /f @path">nul 2>nul
ant -f CIMSmokeTest.xml>%AutoPath%\Result\log.txt
pause
@echo off
color 0a
echo autotest beginning,Please Wait... ...
set AutoPath=%~dp0
%AutoPath:~0,2%
pushd %AutoPath%
cd /d %AutoPath%
set JmeterPath=..\..\..\
echo AutoPath=%AutoPath%
echo JmeterPath=%JmeterPath%
forfiles /p %AutoPath%Result /m *.jtl -d -7 /c "cmd /c del /f @path">nul 2>nul
forfiles /p %JmeterPath%extras /m *.html -d -7 /c "cmd /c del /f @path">nul 2>nul
ant -f CIMSmokeTest.xml>%AutoPath%\Result\log.txt
pause
相关文章推荐
- 在Windows server 2008下计划任务无法正常执行bat批处理文件的问题
- Python脚本在crontab定时任务中无法运行,但是对应脚本手动执行成功
- 在Windows server 2008下计划任务无法正常执行bat批处理文件的问题
- Windows Server 2008中使用计划任务定时执行BAT批处理文件图文教程
- Windows Server 2008中使用计划任务定时执行BAT批处理文件图文教程
- 批处理在任务计划中重复执行, 并且后台运行的实现
- [Shell]crontab 运行任务调用shell脚本,相对路径无法找到
- Windows Server 2008中使用计划任务定时执行BAT bat进行PHP脚本的执行
- 利用windows计划任务定时调用BAT执行oracle数据库重建索引
- MySQL定时执行脚本(计划任务)实例
- MySQL定时执行脚本(计划任务)命令实例
- 【定时任务|开机启动】Windows Server 2008/2012 计划任务配置(任务计划程序)每分钟执行BAT
- [Shell]crontab 执行任务调用shell脚本,相对路径无法找到
- Windows 任务计划程序定时执行 powershell 脚本
- MySQL定时执行脚本(计划任务)命令实例
- MySQL定时执行脚本(计划任务)命令实例
- 关于window2008计划任务前台显示和批处理无法正常执行问题的解决办法
- win7计划任务定时执行PHP脚本设置图解
- win7计划任务定时执行PHP脚本设置图解
- 任务计划无法正常运行批处理文件的解决方法