February 26, 2015 at 11:56 am
Hello,
I am using SQL server 2012 and the operating system is windows server 2012 64 bit.
I am trying to run a batch file from a SQL server agent job. I have the job set up as Type: Operating system(CMDExec), and my command is cmd.exe /c "C:\SQLProcesses\Occupancy.bat".
Everytime I run the job I get the error: 'java' is not recognized as an internal or external command, operable program or batch file. Process Exit Code 1. The step failed.
The batch file itself runs fine when I double click on it, and I can run it from the windows task scheduler just fine.
Does anyone have a suggestions on how I can get the batch file to run from SQL Server Job agent.
Thanks,
Sam
February 26, 2015 at 2:46 pm
samgdavisne (2/26/2015)
Hello,I am using SQL server 2012 and the operating system is windows server 2012 64 bit.
I am trying to run a batch file from a SQL server agent job. I have the job set up as Type: Operating system(CMDExec), and my command is cmd.exe /c "C:\SQLProcesses\Occupancy.bat".
Everytime I run the job I get the error: 'java' is not recognized as an internal or external command, operable program or batch file. Process Exit Code 1. The step failed.
The batch file itself runs fine when I double click on it, and I can run it from the windows task scheduler just fine.
Does anyone have a suggestions on how I can get the batch file to run from SQL Server Job agent.
Thanks,
Sam
Check your java path on Windows.
Based on the error you gave, it seems to me that when running as a TSQL job, SQL server cannot find the path for Java. You may have to add it or correct that.
February 22, 2016 at 6:29 am
Hi All
Sorry to bring up such an old post again, but I'm running into the exact same issue as the original poster.
I have checked my Java path variables and everything seems correct.
Does anyone have any advice?
February 22, 2016 at 6:33 am
Check the path variable for the SQL Agent service account. Path variables are profile specific, and SQL Agent doesn't use your login to run.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 23, 2016 at 12:57 am
Hi Gail
Thanks very much for the advice - it was indeed a problem with the path variable, and was account specific.
I checked the path variable on both my personal domain account and on the SQL Server Agent account (by running ECHO %PATH% via the command line and SQL Server job step respectively), and found that in the latter, no reference was made to the JRE\bin directory.
The problem was that the SQL Server Agent service was not restarted since I installed the JRE - a quick restart of the service did the trick.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply