批量手动运行良好。但是从任务调度程序运行时会出错

时间:2015-04-21 09:54:42

标签: windows batch-file scheduled-tasks task windows-server-2008-r2

在Windows Server 2008上,我正在安排一项任务来运行批处理文件,而该批处理文件又会触发控制台应用程序。双击应用程序时,它运行完美。但是当从任务调度程序运行时,我在日志中得到以下错误。

exception from hresult 0x800a03ec

我登录并运行任务计划程序的ID具有完全管理权限。

我试过这些解决方案.. 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

但问题没有解决。事实上,当从任务调度程序运行时,它会在控制台应用程序中触发成功和异常邮件。但手动运行时并非如此。需要帮助!!

注意:我通过控制台应用程序处理的所有输出报告都是.xlsx格式。

批处理文件如下所述

@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 /**********************************************/

1 个答案:

答案 0 :(得分:2)

最后问题已经解决。我不认为批处理文件或应用程序有任何问题。

此解决方案在......

·Windows 2008 Server x64

请创建此文件夹。

C:\的Windows \ Syswow64资料\配置\ systemprofile \桌面

·Windows 2008 Server x86

请创建此文件夹。

C:\的Windows \ system32 \设置\ systemprofile \桌面

...而不是dcomcnfg.exe。

此操作消除了我系统中的办公自动化问题。

在systemprofile文件夹中似乎需要一个Desktop文件夹来通过Excel打开文件。

它从Windows2008中消失,Windows2003有了该文件夹, 我认为这会导致这个错误。

我在下面提到的链接中找到了这个答案。回答小川。

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

但我不知道如何通过创建一个空文件夹解决了这个问题。但它确实有效..希望这对有类似问题的人有用