使用SYSTEM帐户从Windows Server 2012中的任务计划程序通过批处理文件运行java [英] Issue running java via batch file from Task Scheduler in Windows Server 2012 with SYSTEM account

查看:446
本文介绍了使用SYSTEM帐户从Windows Server 2012中的任务计划程序通过批处理文件运行java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows Server 2012中看到了这种奇怪的行为,它运行的是一个只有java -version命令的批处理文件。任务计划在SYSTEM帐户下运行。



批处理文件的内容。



I have seen this bizarre behavior in windows server 2012 which is running a batch file which has only java -version command. Task is scheduled to run under SYSTEM account.

Content of Batch File.

@ECHO OFF

set CLASSPATH=%CLASSPATH%;"C:\java\jre7\bin\javaw.exe;.\activation.jar;.\mail.jar;.\;.\jt400.jar;" 

java -version >> E:\Interface\IF26_ForecastUpload\TEST\LOG\TEST_IF26_LOG.txt 2>&1



当任务计划每天运行一次我得到日志文件中的java版本信息。



如果我将任务更改为多次运行,那么我会在日志中将'java'识别为内部或外部命令错误。此时我没有对批处理文件进行任何更改。只更改了每小时运行的计划任务。



为什么会这样?我在不同的服务器上尝试了同样的事情,那里也有同样任何使用Server 2012的人都能证实吗?任何解决方案?


When Task is scheduled to run once a day I get java version info in log file.

If I change the task to run multiple times then I get 'java' is not recognized as internal or external command error in log. At this point I did not make any changes to batch file. Only changed scheduled task to run every hour.

Why is this the case ? I tried same thing on different server and same issue there. Can anyone with Server 2012 confirm this ? Any solution ?

推荐答案

可能bacuase PATH变量未设置为包含包含java可执行文件的目录。顺便提一下,您的CLASSPATH在上面看起来没有效果,您应该用它们的完整绝对路径替换相对目录。同时删除javaw.exe,它不是路径。
Probably bacuase the PATH variable is not set to include the directory that contains the java executables. Incidentally your CLASSPATH does not look valid above, you should replace the relative directories with their full absolute paths. Also remove javaw.exe, it is not a path.


这篇关于使用SYSTEM帐户从Windows Server 2012中的任务计划程序通过批处理文件运行java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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