Reputation: 101
On Windows Server 2008, i was scheduling a task to run a batch file which in turn will trigger a console application. When double clicked on the application, its running perfectly. But when ran from the task scheduler i was getting the below error in the logs.
exception from hresult 0x800a03ec
The ID with which i was logged in and running task scheduler had full admin rights.
I had tried these solutions.. Batch File runs manually but not in task scheduler
Batch file called by scheduled task throws error when scheduled, runs fine when double clicked
Batch runs manually but not in scheduled task
But the issue is not resolved. Infact when ran from task scheduler its triggering both success and exception mails in the console application. But this is not the case when ran manually. Need help!!
Note: All the output reports i am processing through console application will be in .xlsx format.
The batch file is as mentioned 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 /**********************************************/
Upvotes: 4
Views: 5004
Reputation: 101
Finally the issue had been resolved. I do not think the problem is any way with the batch file or with the application.
This solution is in...
・Windows 2008 Server x64
Please create this folder.
C:\Windows\SysWOW64\config\systemprofile\Desktop
・Windows 2008 Server x86
Please create this folder.
C:\Windows\System32\config\systemprofile\Desktop
...instead of dcomcnfg.exe.
This operation took away office automation problems in my system.
A Desktop folder seems to be necessary in the systemprofile folder to open file by Excel.
It disappears from Windows2008, Windows2003 had the folder, and I think it cause this error.
I found this answer in the link mentioned below. Answer by Ogawa.
But i do not have any idea how by creating a empty folder had solved the issue. But it works.. Hope this will be helpful for some one with similar issue
Upvotes: 4
Reputation: 49167
Following 2 lines could be a problem:
SET DRV=E:\ReportApplication
cd %DRV%\bin\Release\
cd
without parameter /D
does not change current drive. So with current working directory being C:\Windows\System32
as usual on running a batch file with task scheduler, the directory change does not work and %SystemRoot%\System32
(that's better) remains current working directory.
On double clicking a batch file, Windows sets the directory of the batch file as current working directory. This results in a working batch file on double click when it is located on drive E:
.
Solution is:
SET "DRV=E:\ReportApplication"
cd /D "%DRV%\bin\Release\"
Upvotes: 0