批处理文件手动运行,但不能通过Windows 10 Task Scheduler运行 [英] Batch file runs manually but not through Windows 10 Task Scheduler

查看:55
本文介绍了批处理文件手动运行,但不能通过Windows 10 Task Scheduler运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实需要有关从任务计划程序运行 .bat 文件的帮助.

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

它从位置运行时运行,或者在任务计划程序中单击 Run 时运行.

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

仅在用户登录时运行/在用户登录或不登录时运行

用户是我的本地帐户,也是管理员

The user is my local account is also the admin

.bat 文件存储在 C:\ Users \ user1 \ eclipse-workspace \ abc \ 中,这就是我为填写的内容动作" 标签中设置" 下的程序/脚本" .

.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.

我未选中 Conditions (条件)选项卡下的所有选项(试图检查 power 选项,仍然无效).

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文件代码为:

.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

推荐答案

这个救了我:

  • 确保在任务计划程序设置中关闭了以最高特权运行"
  • 在bat文件中,使用 pushd \\ network_drive_name 作为第一行代码
  • 在bat文件的末尾,使用 popd \\ network_drive_name
  • 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

这篇关于批处理文件手动运行,但不能通过Windows 10 Task Scheduler运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆