Batch file runs manually but not through Windows 10 Task Scheduler

柔情痞子 提交于 2019-12-11 09:03:24

问题


I really need help on running a .bat file from the Task Scheduler.

It runs when ran from location or when Run is clicked from Task Scheduler.

It doesnt run on a schedule when Run only when user is logged on / Run when user is logged on or not

The user is my local account is also the admin

.bat file is stored in C:\Users\user1\eclipse-workspace\abc\, and this is what iI have filled in for the Program/Script under Settings in Actions tab.

I have unchecked all options under Conditions tab, (tried checking the power options, still didnt work).

I would prefer to have this option set :: Run when user is logged on or not.

I would like to know what I'm missing or where I'm going wrong with this.

.bat file code is :

cd C:\Users\user1\eclipse-workspace\abc
set ProjectPath=C:\Users\user1\eclipse-workspace\abc
echo %ProjectPath%
set classpath=%ProjectPath%\bin;%ProjectPath%\Lib\*
echo %classpath%
java org.testng.TestNG %ProjectPath%\testng.xml
pause

回答1:


This one saved me:

  • Make sure "Run with highest privileges" is turned off in your task scheduler settings
  • In your bat file, use pushd \\network_drive_name as the first line of code
  • At the end of your bat file, use popd \\network_drive_name


来源:https://stackoverflow.com/questions/50535935/batch-file-runs-manually-but-not-through-windows-10-task-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!