We help IT Professionals succeed at work.
Get Started

Running JetReport via Task Scheduler

Last Modified: 2015-05-17
I have a script that is run daily via task scheduler to generate reports with JetReport/AutoPilot.exe. Excel is installed and set up with a user named jetreport on the server that runs the task scheduled script. When running the script from cmd as this user, JetReport/AutoPilot.exe generates the reports as desired. However, if run via task scheduler then the reports are never generated but the log file still gets updated with action related information.

:: Find WeekNumber
SET /a D=1%DATE:~0,2% - 100
SET /a M=1%DATE:~3,2% - 100
SET /a Y=%DATE:~6,4%
SET /a N=(1461 * (%Y% + 4800 + (%M% - 14) / 12)) / 4 + (367 * (%M% - 2 - 12 * ((%M% - 14) / 12))) / 12 - (3 * ((%Y% + 4900 + (%M% - 14) / 12) / 100)) / 4 + %D% - 32075
SET /a T=(%N% + 31741 -(%N% %% 7)) %% 146097 %% 36524 %% 1461
SET /a W=((((%T% - (%T% / 1460)) %% 365) + (%T% / 1460)) / 7) + 1 
SET WeekNumber=WEEK %W%

:: Format Date
SET Fdate=%date:~-4,4%.%date:~-7,2%.%date:~-10,2%

:: Input file
SET Sales=Sales ver5.0.xlsx

:: Set paths
SET ReportPath=\\mydomain.com\share\finance\JetReport
SET AutoPilot="%ProgramFiles(x86)%\JetReports\AutoPilot.exe"
SET path2=%ReportPath%\reportset\AutoUpdate
SET Output=%ReportPath%\AutoOutput
SET logfile=%ReportPath%\reportset\Script\log\logfile_week_%W%.log

echo %DATE%	%TIME%  Generate Report daily starts >> %logfile%
::@ECHO %W% - %fdate%

:: Create output folder
IF exist "%output%\%WeekNumber%" (Echo folder exist) else (mkdir "%output%\%WeekNumber%")

:: Create Excel
::@ECHO on
echo %DATE%	%TIME%	%WeekNumber%\Sales %Fdate%.xlsx >> %logfile%
%AutoPilot% /M "VALUES" /I "%path2%\%Sales%" /O "%Output%\%WeekNumber%\Sales %Fdate%.xlsx" >> %logfile%
IF %ERRORLEVEL% neq 0 echo %DATE%	%TIME% Error Level is %ERRORLEVEL% >> %logfile%

:: Create PDF
echo %DATE%	%TIME%	%WeekNumber%\Sales %Fdate%.pdf >> %logfile%
%AutoPilot% /M "PDF" /I "%path2%\%Sales%" /O "%Output%\%WeekNumber%\Sales %Fdate%.pdf" >> %logfile%
IF %ERRORLEVEL% neq 0 echo %DATE%	%TIME% Error Level is %ERRORLEVEL% >> %logfile%
echo %DATE%	%TIME%	Generate Report daily ends >> %logfile%


Open in new window

Here is the output in the log file(but no reports):

27.04.2015      11:44:16,46      WEEK 18\Sales 2015.04.27.xlsx
27.04.2015      11:44:17,55      WEEK 18\Sales 2015.04.27.pdf
27.04.2015      11:44:18,38      Generate Report daily ends

The script is run from a UNC location. I have tried to copy the script to a local folder and change the ReportPath variable to a local folder, but that has given me the same result. I tried running the task with my domain administrator account, and that did not change the result.

The operating system of the server running the scheduled task is Windows Server 2012 R2 Build 9600.
Watch Question
Most Valuable Expert 2012
Top Expert 2008
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE