The package works manually. But when launched from Task scheduler, I get an error

On Windows Server 2008, I scheduled a task to run a batch file, which in turn launches a console application. When you double click on the app, it works fine. But when running from task scheduler I was getting below error in logs.

exception from hresult 0x800a03ec

The ID with which I was registered and executed the task scheduler had full administrator rights.

I have tried these solutions. The batch file is started manually, but not in the task scheduler

Batch file triggered by scheduled job throws an error when scheduling, works fine on double click

The package runs manually, but not in a scheduled task

But the problem has not been resolved. Infact, when launched from Task Scheduler, runs both successful and exception emails in a console application. But this is not the case when you started manually. Help is needed!

Note. All output reports processed through the console application will be in .xlsx format.

The batch file is listed below:

@ECHO. 
@ECHO /***************************************************************/ 
@ECHO               Report Application 
@ECHO /**************************************************************/
@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( 
            Set Month=%%A
            Set Day=%%B
                Set Year=%%C
)

 SET DRV=E:\ReportApplication
cd %DRV%\bin\Release\

ReportSolution.exe >> %DRV%\Log\ReportSolutionlog%Month%%DAY%%Year%.txt
cd\
cd %DRV%


@ECHO  Application is completed successfully
@ECHO /**********************************************/

      

+3


source to share


2 answers


Finally, the problem was resolved. I don't think the problem is with the batch file or with the application.

This solution is in ...

Windows 2008 Server x64

Create this folder.

C: \ Windows \ SysWOW64 \ Config \ systemprofile \ Desktop

Windows 2008 Server x86

Create this folder.

C: \ Windows \ System32 \ Config \ systemprofile \ Desktop



... instead of dcomcnfg.exe.

This operation fixed the office automation issues on my system.

The desktop folder appears to be required in the systemprofile folder to open the Excel file.

It disappears from Windows2008, Windows2003 has a folder and I think it is causing this error.

I found this answer in the link mentioned below. The answer to this question is Ogawa.

https://social.msdn.microsoft.com/Forums/en-US/b81a3c4e-62db-488b-af06-44421818ef91/excel-2007-automation-on-top-of-a-windows-server-2008-x64? forum = innovateonoffice

But I don't know how by creating an empty folder solved the problem. But it works. Hope this will be helpful for someone with a similar problem.

+2


source


The next two lines can be a problem:

SET DRV=E:\ReportApplication
cd %DRV%\bin\Release\

      

cd

without parameter /D

does not change the current disk. So, with the current working directory C:\Windows\System32

, as usual, when you run the batch file with the task scheduler, changing the directory does not work, but %SystemRoot%\System32

(which is better) remains the current working directory.



When you double-click a batch file, Windows sets the batch file directory as the current working directory. This creates a working batch file with a double click when it is on disk E:

.

Decision:

SET "DRV=E:\ReportApplication"
cd /D "%DRV%\bin\Release\"

      

0


source







All Articles